【问题标题】:p:captcha throws - Blocked loading mixed active content on FireFoxp:captcha throws - 阻止在 FireFox 上加载混合的活动内容
【发布时间】:2015-03-03 12:48:51
【问题描述】:

我在尝试使用 <p:captcha> 时遇到问题。我在 FireFox v34.0.5 中收到以下错误:

Blocked loading mixed active content "http://www.google.com/recaptcha/api/challenge?k=xxxxxxxxxxxxxxxxxxxxxxxxx"

检查按钮显示,但验证码图像不显示

我的应用程序托管在安全 (HTTPS) 服务器中,但验证码似乎使用 HTTP 连接到非安全服务器

这是我的 web.xml 文件:

<context-param>
    <param-name>primefaces.PUBLIC_CAPTCHA_KEY</param-name>
    <param-value><xxxxx_recaptcha_generated_public_captcha_key></param-value>
</context-param>
<context-param>
    <param-name>primefaces.PRIVATE_CAPTCHA_KEY</param-name>
    <param-value><xxxxx_recaptcha_generated_private_captcha_key></param-value>
</context-param>

还有我的视图文件(forgottenOPassword.xhtml):

<p:captcha label="Captcha" rendered="#{passBB.showCaptcha}"/>

<p:commandButton actionListener="#{passBB.verifyCaptcha}"
                 ajax="false" 
                 icon="ui-icon-check"
                 rendered="#{passBB.showCaptcha}"
                 value="Check"/>

【问题讨论】:

标签: jsf firefox primefaces captcha


【解决方案1】:

&lt;p:captcha&gt;secure 属性设置为true。另请参阅VDL documentation“启用 https 支持”

<p:captcha ... secure="true" />

或者如果你想让它依赖于当前请求(例如,当你有 2 个版本的 webapp 并且验证码被放置在一些可重用的标签文件/组件中时),然后检查 HttpServletRequest#isSecure()

<p:captcha ... secure="#{request.secure}" />

无论哪种方式,如果计算结果为true,则为CaptchaRenderer will use https instead of http

【讨论】:

  • 感谢@BalusC,您的回答解决了我的问题。我稍后会测试它,然后我会给你积分
猜你喜欢
  • 2018-07-30
  • 2014-01-03
  • 1970-01-01
  • 2017-01-23
  • 2017-05-12
  • 1970-01-01
  • 1970-01-01
  • 2018-12-04
  • 2019-06-09
相关资源
最近更新 更多