M
Mackuack
Hello everybody
i have the following code to access an application via https:
---------------------------------------------
System.Net.ServicePointManager.CertificatePolicy = new
TrustAllCertificatePolicy();
httpWebRequest = (HttpWebRequest)WebRequest.Create(url);
X509Certificate cer =
X509Certificate.CreateFromCertFile(@"c:\CertificadoCliente.cer");
httpWebRequest.ClientCertificates.Add(cer);
httpWebRequest.Method = "POST";
httpWebRequest.ContentLength = stringPost.Length;
streamWriter = new StreamWriter(httpWebRequest.GetRequestStream());
streamWriter.Write(stringPost);
streamWriter.Close();
HttpWebResponse httpWebResponse =
(HttpWebResponse)httpWebRequest.GetResponse();
StreamReader streamReader = new
StreamReader(httpWebResponse.GetResponseStream());
respuesta = streamReader.ReadToEnd();
streamReader.Close();
---------------------------------------------
Although the connection is created (i think the certificates are
correctly installed), i got an exception when i try to close the
streamWriter:
"Cannot access a disposed object named \"System.Net.TlsStream\"."
As you can see i have created the TrustAllCertificatePolicy class, but
i still get that exception. Could anyone help me?
Thanks in advance. Patricio.
i have the following code to access an application via https:
---------------------------------------------
System.Net.ServicePointManager.CertificatePolicy = new
TrustAllCertificatePolicy();
httpWebRequest = (HttpWebRequest)WebRequest.Create(url);
X509Certificate cer =
X509Certificate.CreateFromCertFile(@"c:\CertificadoCliente.cer");
httpWebRequest.ClientCertificates.Add(cer);
httpWebRequest.Method = "POST";
httpWebRequest.ContentLength = stringPost.Length;
streamWriter = new StreamWriter(httpWebRequest.GetRequestStream());
streamWriter.Write(stringPost);
streamWriter.Close();
HttpWebResponse httpWebResponse =
(HttpWebResponse)httpWebRequest.GetResponse();
StreamReader streamReader = new
StreamReader(httpWebResponse.GetResponseStream());
respuesta = streamReader.ReadToEnd();
streamReader.Close();
---------------------------------------------
Although the connection is created (i think the certificates are
correctly installed), i got an exception when i try to close the
streamWriter:
"Cannot access a disposed object named \"System.Net.TlsStream\"."
As you can see i have created the TrustAllCertificatePolicy class, but
i still get that exception. Could anyone help me?
Thanks in advance. Patricio.