HttpWebRequest encapsulate client certificate

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?
 
E

Eliyahu Goldin

/// <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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,581
Members
45,056
Latest member
GlycogenSupporthealth

Latest Threads

Top