Tuesday, March 27, 2012

How to pass user certificate to the server to establish HTTP/SSL/TSL connection

Alternative Titles 
  • How to present user certificate to the server to establish HTTP/SSL/TSL connection
  • How to use HTTP channel with HttpWebclient  
  • 400 forbidden exception when tried to connect a server that expect certificate. 
Problem
400 forbidden exception when tried to connect a server that expect certificate.

Solution
In order to solve this problem you need to pragmatically discover user certificate in your user store and then need to attach with server. it is two step process 
  • Attach the same to your HTTP web request instance 
X509Certificate userCert = CertificateHalper.GetClientCertificate(“User Name”);
WebReq.ClientCertificates.Add(userCert);

No comments:

Post a Comment