I am posting data to BluPay. It is working on production but not working on the Test server. It is throwing this exception:

The remote certificate is invalid according to the validation procedure.

In code, we have already support to TLS.1.2 but still, the problem exists. I have tried the below code to handle the certificate validation event to make it easier to determine the reason why the remote certificate is considered invalid. I got below exact error from this code.

ServicePointManager.ServerCertificateValidationCallback = new RemoteCertificateValidationCallback(ValidateServerCertificate);

Below error, I got from this code.

System.Net.Security.SslPolicyErrors.RemoteCertificateChainErrors.

when I check Chain then it showing me below problem.

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.

This below code I am using to post a request and this Stream postdata = request.GetRequestStream(); throwing this error.

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);

0 Answers