X509Certificate

J

Joe Kinsella

I'm porting a small piece of Java that will fetch HTML from a secured web
page. The Java code was purposely written to accept any client
certificate - even out of date certificates. This was accomplished by
implementing an X509TrustManager that accepted any certificate.

I'm trying to understand how to do the equivalent in .Net.

Does anyone know how to do this? Help would be very much appreciated.
Thanks in advance.

Joe
 
L

Luke Zhang [MSFT]

In VS.NET, we can retrieve HTML with a HttpWebRequest object, it has a
property named "ClientCertificates", we can specify the certificates here.
Here is some sample code:

wreq.Method = "POST";
string poststring = postParameters ;
wreq.ContentType = "text/xml";

X509Certificate A2WCert = X509Certificate.CreateFromCertFile("c:\c1.cer");
wreq.ClientCertificates.Add(A2WCert);

HttpWebResponse wresp= (HttpWebResponse)wreq.GetResponse();

Client certificates Accepted by serverside replys on IIS. By default, it
will reject a out-of-date client certificate.

For more information, you may check docuements on following namespace in
MSDN:

System.Security.Cryptography.X509Certificates

Luke

(This posting is provided "AS IS", with no warranties, and confers no
rights.)
 

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

Top