【问题标题】:Loading javascript or css files from external URL giving Warning insecure content从外部 URL 加载 javascript 或 css 文件给出警告不安全内容
【发布时间】:2013-09-03 11:35:58
【问题描述】:

我正在这个小工具中开发一个 gmail 上下文小工具,有一些图像。谁能告诉我如何在上下文小工具中加载图像。例如,我将我的方法规范托管在 http://cloudfactor9.appspot.com/first_app3.xml 并且有 http://cloudfactor9.appspot.com/assets/img/cflogo.png 时在 first_app3.xml 我声明一个

<img src="assets/img/man.png" class="man-image"><img>

它给了我 404 not found 错误。

当我以这种方式声明 img 元素时,它会给我警告

<img src="http://cloudfactor9.appspot.com/assets/img/man.png" class="man-image"><img>


Warning: The page at https://mail.google.com/mail/u/0/?ui=2&shva=1#inbox/140d95d0cccc60a5 displayed insecure content from http://cloudfactor9.appspot.com/assets/img/cflogo.png.

我想摆脱这个警告。在谷歌上下文小工具中加载图像、javascript和样式表的正确方法是什么,请指导。

【问题讨论】:

  • 注意 gmail 使用 https 并且您的图片 URL 有 http

标签: google-app-engine google-apps google-gadget gmail-contextual-gadgets


【解决方案1】:

您遇到了here 中描述的“不安全内容”问题(适用于 Google Chrome,但适用于所有主要浏览器)。您应该配置您的应用程序“cloudfactor9”以强制在部分(或全部)URL 上建立安全连接,如 here 所述:

<security-constraint>
    <web-resource-collection>
        <web-resource-name>profile</web-resource-name>
        <url-pattern>/profile/*</url-pattern>
    </web-resource-collection>
    <user-data-constraint>
        <transport-guarantee>CONFIDENTIAL</transport-guarantee>
    </user-data-constraint>
</security-constraint>

然后您可以通过 HTTPS (https://cloudfactor9.appspot.com/assets/img/cflogo.png) 从通过 HTTPS 检索的页面(如邮件中的那些)访问您的资源.google.com)。

【讨论】:

  • @ritesh-mehandiratta,如果(且仅当)我的回答对您有所帮助,请随时点击左侧的复选标记符号接受它:)
【解决方案2】:

您的静态内容是通过不安全的协议 (http) 提供的,因此会发出警告。正确的方法是仅将您的静态内容包含在“协议相对”URL 中。例如,你会这样做;

【讨论】:

    猜你喜欢
    • 2011-01-06
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-07-13
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-10-26
    相关资源
    最近更新 更多