我正在将数据发布到BluPay。它正在生产中,但不在测试服务器上。引发此异常:
The remote certificate is invalid according to the validation procedure.
在代码中,我们已经支持TLS.1.2,但是仍然存在问题。 我已经尝试使用以下代码来处理证书验证事件,以便更轻松地确定将远程证书视为无效的原因。我从此代码中得到了确切的错误。
ServicePointManager.ServerCertificateValidationCallback = new RemoteCertificateValidationCallback(ValidateServerCertificate);
下面的错误,我从这段代码中得到的。
System.Net.Security.SslPolicyErrors.RemoteCertificateChainErrors.
当我检查Chain时,它向我显示以下问题。
The revocation function was unable to check revocation because the revocation server was offline.
The revocation function was unable to check revocation for the certificate.
以下我用来发布请求的以下代码,该Stream postdata = request.GetRequestStream();
引发此错误。
System.Net.ServicePointManager.SecurityProtocol = System.Net.SecurityProtocolType.Tls12;
System.Net.ServicePointManager.Expect100Continue = true;
System.Net.ServicePointManager.DefaultConnectionLimit = System.Net.ServicePointManager.DefaultPersistentConnectionLimit;
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(this.URL);
request.AllowAutoRedirect = false;
ServicePointManager.CheckCertificateRevocationList = true;
requestData = post;
byte[] data = Encoding.ASCII.GetBytes(post);
request.Method = "POST";
request.ContentType = "application/x-www-form-urlencoded";
request.ContentLength = data.Length;
request.Timeout = timeout;
Stream postdata = request.GetRequestStream();
postdata.Write(data, 0, data.Length);
postdata.Close();
// Get response
GetResponse(request);