gpt4 book ai didi

angularjs - angular.service 调用错误:net::ERR_INSECURE_RESPONSE

转载 作者:太空宇宙 更新时间:2023-11-03 14:57:57 36 4
gpt4 key购买 nike

当我的 Angular 脚本尝试访问我的 WCFservice 方法时,我收到错误 net::ERR_INSECURE_RESPONSE。为了使其正常工作,每个访问该网站的浏览器都需要找到在 ajax 调用中使用的 url,并手动将证书添加到其受信任的站点。如果不购买真正的证书,就没有办法自动完成吗?为了解决这个问题,我尝试了三件事:

  1. 在每个人的服务开放请求上设置 crossdomain.xml
<?xml version="1.0" ?>
<cross-domain-policy>
<site-control permitted-cross-domain-policies="master-only"/>
<allow-access-from domain="*"/>
<allow-http-request-headers-from domain="*" headers="*"/>
</cross-domain-policy>

仍然出现同样的错误 net::ERR_INSECURE_RESPONSE

  1. 在 Angular 请求中发送以下 header
Access-Control-Allow-Origin:*
Access-Control-Allow-Methods:GET, POST
Access-Control-Allow-Headers: Content-Type, Accept,TOKEN

仍然出现同样的错误 net::ERR_INSECURE_RESPONSE

  1. 已关注 this link尽我所能设置自定义自签名证书,但是在服务器上的 IIS 中设置绑定(bind)时出现此错误:

one or more intermediate certificates in the certificate chain are missing. To resolve this issue, make sure that all of the intermediate certificates are installed

我已经在 Windows Server 2012 上部署了 WCF 4.0 REST 服务。我想我需要正确理解第 3 点才能使其正常工作。我需要帮助来理解如何解决第 3 点提到的错误。

The Website url: https://www.mydomain.com/Website/  
The Service url: https://www.mydomain.com/Webservice/

感谢任何帮助。

最佳答案

我在需要创建用于测试的自签名证书的环境中工作了一段时间。我们使用 java keytool 来创建证书。使用此链接 To Use keytool to Create a Server Certificate和谷歌获取更多信息以创建您自己的证书。该过程非常复杂(虽然比您提供的链接更简单),但关键是在创建证书时使用您的机器名称,并确保您用于测试的 url 使用此名称。

您可能还需要将机器名称及其 IP 添加到主机文件中。这很重要,以便通过证书上的名称解析 url。您将需要弄清楚如何将证书添加到您的服务器。我们使用了 Tomcat,请参阅此 /ssl-howt ,或者对于节点,试试这个 create a trusted self-signed SSL cert for localhost (for use with Express/Node) . (不幸的是我从未使用过IIS)

最后要检查您的证书是否有效,您必须将服务器配置为在 ssl 模式下运行,并且在尝试将这些作为服务从您的网页中使用之前,您应该能够访问。

https://yourmachinemane:443/suburls

关于angularjs - angular.service 调用错误:net::ERR_INSECURE_RESPONSE,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26734269/

36 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com