Chrome iFrame Block HTTPS redirect

 ̄綄美尐妖づ 提交于 2019-12-23 08:57:04

问题


I've got a parent site : https://a.company.com, which contains an iframe with https content (https://b.company.com/foo) and everything is happy so far. But, when a redirect occurs to load a different route on that same domain, chrome blocks it as a mixed content error. Viewing the request in the network traffic confirms that the browser is requesting https, yet chrome still cancels the request citing that I can't load mixed (http) content.

All searching has got me so far is to people trying to load mixed content which is not the case here.

For reference this is the chrome error: Mixed Content: The page at 'https://a.company/foo' was loaded over HTTPS, but requested an insecure resource 'http:/b.company/bar'. This request has been blocked; the content must be served over HTTPS.

The actual frame source is https:/b.company/foo which has a possible redirect to https:/b.company/bar. If the page does not redirect no error occurs.


回答1:


Old question but still relevant so I will try to answer this.

As previously stated: You are not allowed to load unsafe http-content within a https-served website since it would compromise the security. If you try to do it anyway, Chrome will prevent it and throw the before mentioned error.

The first step to ensure that you are indeed requesting via https is to check the URL in the iframe, which should look like this:

<iframe src="https://foobar.com"></iframe>
                ↑
          this needs to be https

Now take that exact URL and paste it into any browser to see what rules are in place. If you are redirected in any way it is possible that a unsafe http-connection is used after or in between the redirects. They might even have a straight https-to-http rule in place (unlikely). Also check the console since they might attempt to load unsafe content within their https-served page as well which could result in an error on your end. If you find one of those things but you have no access to the server your journey ends here unless you want to serve that content so badly that you are willing to use http yourself.

If you, on the other hand, have access to the server you could remove those redirects or check their configuration. Since there are many different web-servers, operating systems and configurations I won't attempt to give a general tutorial but it shouldn't be hard to find with the search engine of your choosing.

Generally speaking: If the content you want to load is served exclusively via https it will work.

When everything in the browser seems to work correctly (no visible redirects) and you still get the error you could use Wireshark or other tools to log your traffic. It could be a misconfigured https that messes up the handshake in some way Chrome doesn't like. Post those logs on SO or share the website you want to display in your iframe so we can analyze it further since it is unlikely that there is a general solution.



来源:https://stackoverflow.com/questions/29705920/chrome-iframe-block-https-redirect

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!