简体   繁体   English

如何从 HTTPS 网站发出 HTTP 请求?

[英]How can I make an HTTP request from an HTTPS website?

I have a website which is on HTTPS, and I want to make a GET request to an HTTP port.我有一个使用 HTTPS 的网站,我想向 HTTP 端口发出 GET 请求。 At the moment when I try I get these errors:在我尝试的那一刻,我收到了这些错误:

cannot load ${url} due to access control checks.

this page was not allowed to display insecure content from ${http-url}

I have thought about putting the request in an AWS lambda function and calling the labmda function because that will give me an HTTPS URL?我想过将请求放入 AWS lambda 函数并调用 labmda 函数,因为这会给我一个 HTTPS URL? Is this possible.这可能吗。

Even so, I want to know what the easiest way of doing it is, as I don't know much about AWS so I would have to learn it.尽管如此,我想知道最简单的方法是什么,因为我对 AWS 了解不多,所以我必须学习它。

const url = 'http://website/fmi/xml/fmresultset.xml?-dbnames';

var xhttp = new XMLHttpRequest(); 
xhttp.onreadystatechange = function (params) { 
  console.log(xhttp.status); 
  if (xhttp.readyState ==4) { 
    if (xhttp.status == 200) { 
      console.log('===='); 
      console.log(xhttp.responseText); 
    } 
  } 
} 
xhttp.open("GET", url, true); 
xhttp.send();

Well you can't browser will block any resources ( scripts , link , iframe , XMLHttpRequest, fetch ) to download if original html page is in https and request resources are in http.好吧,如果原始 html 页面在 https 中并且请求资源在 http 中,浏览器将不会阻止任何资源(脚本、链接、iframe、XMLHttpRequest、fetch)下载。

Browser throws an Mixed Content error.浏览器抛出Mixed Content错误。

Snippet from Mozilla MDN摘自 Mozilla MDN

Mixed active content is content that has access to all or parts of the Document Object Model of the HTTPS page.混合活动内容是可以访问 HTTPS 页面的全部或部分文档对象模型的内容。 This type of mixed content can alter the behavior of the HTTPS page and potentially steal sensitive data from the user.这种类型的混合内容可以改变 HTTPS 页面的行为,并可能窃取用户的敏感数据。 Hence, in addition to the risks described for mixed display content above, mixed active content is vulnerable to a few other attack vectors.因此,除了上述混合显示内容的风险外,混合活动内容还容易受到其他一些攻击媒介的攻击。

In the mixed active content case, a man-in-the-middle attacker can intercept the request for the HTTP content.在混合活动内容的情况下,中间人攻击者可以拦截对 HTTP 内容的请求。 The attacker can also rewrite the response to include malicious JavaScript code.攻击者还可以重写响应以包含恶意 JavaScript 代码。 Malicious active content can steal the user's credentials, acquire sensitive data about the user, or attempt to install malware on the user's system (by leveraging vulnerabilities in the browser or its plugins, for example).恶意活动内容可以窃取用户的凭据、获取有关用户的敏感数据或尝试在用户系统上安装恶意软件(例如,通过利用浏览器或其插件中的漏洞)。

The risk involved with mixed content does depend on the type of website the user is visiting and how sensitive the data exposed to that site may be.混合内容所涉及的风险取决于用户访问的网站类型以及暴露于该网站的数据的敏感程度。 The webpage may have public data visible to the world or private data visible only when authenticated.该网页可能具有全世界可见的公共数据或仅在经过身份验证时才可见的私有数据。 If the webpage is public and has no sensitive data about the user, using mixed active content still provides the attacker with the opportunity to redirect the user to other HTTP pages and steal HTTP cookies from those sites.如果网页是公开的并且没有关于用户的敏感数据,使用混合活动内容仍然为攻击者提供了将用户重定向到其他 HTTP 页面并从这些站点窃取 HTTP cookie 的机会。

Useful documentation links有用的文档链接

MDN - https://developer.mozilla.org/en-US/docs/Web/Security/Mixed_content MDN - https://developer.mozilla.org/en-US/docs/Web/Security/Mixed_content

Google developers - https://developers.google.com/web/fundamentals/security/prevent-mixed-content/what-is-mixed-content Google 开发人员 - https://developers.google.com/web/fundamentals/security/prevent-mixed-content/what-is-mixed-content

Don't use Ajax calls as they are restricted by browser.不要使用 Ajax 调用,因为它们受浏览器限制。 You can safely use Server call with Server side Language like php node.js ,Asp.net etc您可以安全地将服务器调用与服务器端语言(如 php node.js 、Asp.net 等)一起使用

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM