我有一个功能应用程序,我收到此错误:
I have a function app in which I get this error :
有时可以正常工作,有时却不行。具有相同的查询参数且无更改。
It works ok sometimes and doesn't at other times. With the same query parameters and no changes.
System.Net.Http.HttpRequestException:无法建立SSL连接,请参阅内在的例外。 ---> System.Security.Authentication.AuthenticationException:根据验证程序,远程证书无效。
System.Net.Http.HttpRequestException: The SSL connection could not be established, see inner exception. ---> System.Security.Authentication.AuthenticationException: The remote certificate is invalid according to the validation procedure.
推荐答案
从描述中有功能应用程序中的代码对使用仅在您的网络中受信任的证书的后端服务的HTTPS请求。由于Web应用程序/功能应用程序服务器没有受信任的根证书,因此失败并显示"不受信任"错误。如果我误解了配置,请告诉我。
但是,以下信息基于该特定假设。
遗憾的是,由于安全问题,无法将证书导入Azure Web Apps / Function应用程序中的受信任根存储。解决此错误的唯一选择是在应用程序代码中处理类似于此处描述的验证: stackoverflow/a/34204814 。 我们过去曾成功使用过这些步骤,例如:
ServicePointManager.ServerCertificateValidationCallback += (sender, certificate, chain, sslPolicyErrors) => { if (sslPolicyErrors == SslPolicyErrors.None) { return true; } var certStore = new X509Store(StoreName.My, StoreLocation.CurrentUser); certStore.Open(OpenFlags.ReadOnly); var certCollection = certStore.Certificates.Find(X509FindType.FindByThumbprint, "THUMBPRINT", false); if (certCollection.Count > 0) { var validCertificate = certCollection[0]; var passedCert = new X509Certificate2(certificate); certStore.Close(); return validCertificate.Equals(passedCert); } certStore.Close(); return false; };
更多推荐
System.Net.Http.HttpRequestException:SSL
发布评论