X509Certificate

  • Thread starter Thread starter Joe Kinsella
  • Start date Start date
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
 
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.)
 
Back
Top