HttpWebRequest encapsulate client certificate

  • Thread starter Thread starter Frank
  • Start date Start date
F

Frank

Problem....

I need some help, i got an implementation manual wich uses asp (not
..net) code as example. In this example the object 'WinHttp' is
initiated. Now this is an com object and since i'm working in c# i
would like to use managed code. So i figured that i should use the
'HttpWebRequest'. All fine but the WinHttp has got an option to set and
ClientCertificate.

Is there a way a can set an ClientCertificate with HttpWebRequest?
Are there any other options in managed code?
 
/// <summary>Adds client certificate from a cert file to a http web
request.</summary>
/// <param name="req">Http web request.</param>
/// <param name="fileName">Certificate file name.</param>
public static void AddCertificateFromCertFile (HttpWebRequest req, string
fileName)
{
System.Security.Cryptography.X509Certificates.X509CertificateCollection
certColl = req.ClientCertificates;
System.Security.Cryptography.X509Certificates.X509Certificate cert =

System.Security.Cryptography.X509Certificates.X509Certificate.CreateFromCert
File (fileName);
req.ClientCertificates.Add (cert);
}

Eliyahu
 
Back
Top