Click here to Skip to main content
15,177,535 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
See more:

In my C# application, I got to call web service via https and perform peer verification using a ".crt" file. If I add request.ClientCertificates.Add(x5092Obj); then I get exception :
WEB Excep : The underlying connection was closed: Could not establish trust relationship for the SSL/TLS secure channel.
 STATUS = TrustFailure
 STACK =   at System.Net.HttpWebRequest.GetRequestStream(TransportContext& context)
   at System.Net.HttpWebRequest.GetRequestStream()

If I add
ServicePointManager.ServerCertificateValidationCallback += new RemoteCertificateValidationCallback(customXertificateValidation);

that returns true, then it works perfectly even if I remove the request.ClientCertificates.Add line.

If in any circumstances, I got to return true in ServerCertificateValidationCallback and without that request can't receive the client from server. If I add that the .crt file that I am suppossed to use makes no sense.

How do I use the .crt file and confirm that the certificate is valid ? Can any on help me out. I did lots of research on this but couldn't get things to its point. Now am in a hurry to solve the problem. Any help, guidance is highly appreciated.

Updated 18-Apr-11 23:09pm

1 solution


I have solved the problem. Looking at no responses here, thought to share the procedure with all of you over here. You can get to know how to work out with Web Services via HTTPS taking care of SSL Peer Verification at : SSL Peer Verification[^]

Hope it helps.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900