Subra Mallampalli
10/2/2003 7:23:00 PM
Hi,
I am trying to connect over HTTPS using a client certificate. I am able to
connect fine when using IE. From my application, however, I get the
following error:
The underlying connection was closed: Could not establish secure channel for
SSL/TLS.
at System.Net.HttpWebRequest.CheckFinalStatus() at
System.Net.HttpWebRequest.EndGetRequestStream(IAsyncResult asyncResult) at
System.Net.HttpWebRequest.GetRequestStream() at Project1.Page_Load(Object
sender, EventArgs e) in
d:\temp\vswebcache\myMachine\project1\webform1.aspx.cs:line 47.
I have installed the certificate on the development machine and the
certificate has the private key included. From the application, I use a
DER-encoded X.509 certificate which does not include the private key. I am
able to read the certificate and its properties from within the application,
so I know the certificate is fine.
I am attaching the code that I am using. Any help would be greatly
appreciated!
Thanks,
Subra
***************************************************
ServicePointManager.CertificatePolicy = new CertificatePolicy();
X509Certificate cert = X509Certificate.CreateFromCertFile(certfile);
HttpWebRequest req = (HttpWebRequest)WebRequest.Create(url);
req.ClientCertificates.Add(cert);
req.Method = "POST";
req.KeepAlive = false;
req.ContentLength = requestXML.Length;
Stream reqStream = req.GetRequestStream(); //******** error occurs on this
line.
StreamWriter sw = new StreamWriter(reqStream);
sw.Write(requestXML);
sw.Close();
***************************************************