P
Param R.
Hi all, I have an aspx page that needs to call a remote website that is
protected by client cert authentication. I have installed the client cert
and set permissions for IIS_WPG as per
http://support.microsoft.com/default.aspx?scid=kb;en-us;817854. I then
exported the cert to a DER encoded file.
Now here is my code:-
Dim h as httpwebrequest
h = Ctype(WebRequest.Create(strurl), httpwebrequest)
Dim mycert as X509Certificate =
X509Certificate.CreateFromCertFile("c:\inetpub\wwwroot\mycert.cer")
h.clientcertificates.add(mycert)
h.contenttype = "text/xml"
h.method = "POST"
h.contentlength = len(strbody)
Dim s as stream = h.getrequeststream()
Dim sw as new streamwriter(s)
sw.write(strbody)
sw.close()
Dim hr as httpwebresponse = Ctype(h.getresponse(), httpwebresponse)
Dim s2 as stream = hr.getresponsestream()
Dim sr as new streamreader(s2)
returnstr = sr.readtoend()
sr.close()
Now here is the error I am getting back:-
The underlying connection was closed: Could not establish secure channel for
SSL/TLS.
Any Ideas? Please help. The same code works for a page that is not protected
by Client Certs.
thanks!
protected by client cert authentication. I have installed the client cert
and set permissions for IIS_WPG as per
http://support.microsoft.com/default.aspx?scid=kb;en-us;817854. I then
exported the cert to a DER encoded file.
Now here is my code:-
Dim h as httpwebrequest
h = Ctype(WebRequest.Create(strurl), httpwebrequest)
Dim mycert as X509Certificate =
X509Certificate.CreateFromCertFile("c:\inetpub\wwwroot\mycert.cer")
h.clientcertificates.add(mycert)
h.contenttype = "text/xml"
h.method = "POST"
h.contentlength = len(strbody)
Dim s as stream = h.getrequeststream()
Dim sw as new streamwriter(s)
sw.write(strbody)
sw.close()
Dim hr as httpwebresponse = Ctype(h.getresponse(), httpwebresponse)
Dim s2 as stream = hr.getresponsestream()
Dim sr as new streamreader(s2)
returnstr = sr.readtoend()
sr.close()
Now here is the error I am getting back:-
The underlying connection was closed: Could not establish secure channel for
SSL/TLS.
Any Ideas? Please help. The same code works for a page that is not protected
by Client Certs.
thanks!