Hi all,
I'm having trouble connecting to a Java web service using HttpWebRequest. I
get the error message "The request was aborted: Could not create SSL/TLS
secure channel". The Java service requires a client certificate which they
have provided in .cer format. I can connect ok to their test service which
uses SSL but doesnt require a client certificate with the code below.
I dont have great deal of knowledge about client certificates so anyone got
any ideas why this isnt working?
Thanks
Steve
Details are:
Tried using .net 1.1 and .net 2.0.
Running this code from a Winform application.
I'm connecting using the code below
System.Net.Serv icePointManager .CertificatePol icy = new
TrustAllCertifi catePolicy();
string url="https://www.websiteurlh ere.com";
XmlDocument doc = new XmlDocument();
doc.Load(xml file containing request);
string data=doc.InnerX ml;
byte[] buffer=Encoding .UTF8.GetBytes( data);
HttpWebRequest req = (HttpWebRequest )WebRequest.Cre ate(url);
req.Method = "POST";
req.ProtocolVer sion = HttpVersion.Ver sion10;
req.KeepAlive = false;
req.Headers.Cle ar();
X509Certificate cert =
X509Certificate .CreateFromCert File(@"C:\Devel op\cert_sign.ce r");
req.ClientCerti ficates.Add(cer t);
req.ContentLeng th = buffer.Length;
req.ContentType ="applicatio n/x-www-form-urlencoded";
using (Stream reqst = req.GetRequestS tream())
{
reqst.Write(buf fer, 0, buffer.Length);
reqst.Flush();
}
using (HttpWebRespons e response = (HttpWebRespons e)req.GetRespon se())
{
using (Stream rs = response.GetRes ponseStream())
{
using (StreamReader sr = new StreamReader(rs ))
{
string responseDetails = sr.ReadToEnd();
textBox1.Text = responseDetails ;
}
}
}
I'm having trouble connecting to a Java web service using HttpWebRequest. I
get the error message "The request was aborted: Could not create SSL/TLS
secure channel". The Java service requires a client certificate which they
have provided in .cer format. I can connect ok to their test service which
uses SSL but doesnt require a client certificate with the code below.
I dont have great deal of knowledge about client certificates so anyone got
any ideas why this isnt working?
Thanks
Steve
Details are:
Tried using .net 1.1 and .net 2.0.
Running this code from a Winform application.
I'm connecting using the code below
System.Net.Serv icePointManager .CertificatePol icy = new
TrustAllCertifi catePolicy();
string url="https://www.websiteurlh ere.com";
XmlDocument doc = new XmlDocument();
doc.Load(xml file containing request);
string data=doc.InnerX ml;
byte[] buffer=Encoding .UTF8.GetBytes( data);
HttpWebRequest req = (HttpWebRequest )WebRequest.Cre ate(url);
req.Method = "POST";
req.ProtocolVer sion = HttpVersion.Ver sion10;
req.KeepAlive = false;
req.Headers.Cle ar();
X509Certificate cert =
X509Certificate .CreateFromCert File(@"C:\Devel op\cert_sign.ce r");
req.ClientCerti ficates.Add(cer t);
req.ContentLeng th = buffer.Length;
req.ContentType ="applicatio n/x-www-form-urlencoded";
using (Stream reqst = req.GetRequestS tream())
{
reqst.Write(buf fer, 0, buffer.Length);
reqst.Flush();
}
using (HttpWebRespons e response = (HttpWebRespons e)req.GetRespon se())
{
using (Stream rs = response.GetRes ponseStream())
{
using (StreamReader sr = new StreamReader(rs ))
{
string responseDetails = sr.ReadToEnd();
textBox1.Text = responseDetails ;
}
}
}
Comment