as you are creating a new certificate on each request, it unclear why you persist the keys.
How to troubleshot HttpWebRequest if X509Certificate is not added properly
Kuler Master
266
Reputation points
Hello all,
I am adding a X509Certificate to the HttpRequest like the following:
HttpWebRequest request = (HttpWebRequest)WebRequest.Create("webserviceurl");
request.ClientCertificates.Clear();
X509Certificate certificate = new X509Certificate(
certificateFilePath, certificatePassword,
X509KeyStorageFlags.MachineKeySet |
X509KeyStorageFlags.PersistKeySet |
X509KeyStorageFlags.Exportable);
if(certificate != null)
request.ClientCertificates.Add(certificate);
However, sometimes the certificate is not added correctly or is blocked by something (ISP, Firewall etc. etc.) and we get an error from the web service we send it toward. It happens like 3 times out of 10. Meaning it works 3 times, then this problem occurs or works 5 times and then happens 2 times in a row - no specific pattern of when it happens. How do I troubleshot and figure out what could be the reason for this?
Thank you in advance!