我们有一个应用程序(webapi,让我们命名为" x")在Windows Server 2012 R2上使用IIS。有时," X"无法连接到网络上的其他独立API。我们有错误:
基础连接已关闭:无法建立信任 SSL/TLS安全通道的关系。
根据验证,远程证书无效 过程。
我已经进行了一些测试,同时" x"无法下载https://google.com(使用WebClient
类),但我可以在该当前服务器上使用Web浏览器浏览。
我也试图忽略整个应用程序的服务器证书错误(下面的代码),但也没有帮助。
protected void Application_Start()
{
ServicePointManager.ServerCertificateValidationCallback +=
(sender, cert, chain, sslPolicyErrors) => true;
}
我的客户在连接到" X"方面没有问题。同样,当一台服务器上发生错误时,我可以成功连接(例如
可能是什么问题?
听起来您的IIS Web应用程序在无法访问机器上证书的用户上下文下运行。但是,浏览器在具有访问权限的不同用户上下文下运行。这解释了您的测试结果。
如果用户确实可以访问证书,则可能需要从独立API下载证书。请参阅:http://brainof-dave.blogspot.com.au/2008/08/remote-certificate-is-is-invalid-according.html
也查看这些资源:https://blogs.msdn.microsoft.com/saurabh_singh/2009/07/02/required-permissions-permissions-permissions-when-calling-a-web-service-service-service-service-client-client-client-client-certificate-for-authentication-for-authentication-in-an-asp-asp--asp--asp--asp---asp--asp----net-web-application/
https://technet.microsoft.com/en-us/library/cc772237(v = ws.10).aspx