We have some code that does a post to a https address using HttpWebResponse. It works fine on server 2003 with iis 5.x or whatever, but when we try to run it on 2008 with IIS7, it gives us the following error:
System.Net.WebException: The request was aborted: Could not create SSL/TLS secure channel.
I suspected it was a certificate issue or something, so i added the ServicePointManager.ServerCertificateValidationCallback and just returned "true" but the issue still persists.
bryanc
15 Posts
Could not create SSL/TLS secure channel
Apr 07, 2009 09:14 PM|LINK
Hi all,
We have some code that does a post to a https address using HttpWebResponse. It works fine on server 2003 with iis 5.x or whatever, but when we try to run it on 2008 with IIS7, it gives us the following error:
System.Net.WebException: The request was aborted: Could not create SSL/TLS secure channel.
I suspected it was a certificate issue or something, so i added the ServicePointManager.ServerCertificateValidationCallback and just returned "true" but the issue still persists.
this is the relevent code:
HttpWebRequest Req = ((HttpWebRequest)(HttpWebRequest.Create(("https://secure.[siteaddress]?" + postData))));
Req.AllowAutoRedirect = true;
Req.Timeout = 150000;
Req.ProtocolVersion = HttpVersion.Version11;
Req.ContentLength = postData.Length;
Req.ContentType = "application/x-www-form-urlencoded";
Req.KeepAlive = false;
postData = "";
Req.ContentLength = postData.Length;
Req.AllowWriteStreamBuffering = true;
string result;
ServicePointManager.ServerCertificateValidationCallback += new System.Net.Security.RemoteCertificateValidationCallback(ValidateCertificate);
HttpWebResponse objResponse = Req.GetResponse() as HttpWebResponse;
any ideas as to why this is happening?
also, if we just paste the request into the address bar of a browser on the machine, it works with no errors.
JaroDunajsky
194 Posts
Microsoft
Re: Could not create SSL/TLS secure channel
Apr 27, 2009 03:31 AM|LINK
You should use system.diagnostics to get verbose log of what is going on the client side.There may be error details burried in the log.
lextm
4572 Posts
Re: Could not create SSL/TLS secure channel
Apr 27, 2009 09:22 AM|LINK
To see how to enable tracing, please follow this blog post,
http://blogs.msdn.com/asiatech/archive/2009/04/08/using-system-net-trace-to-troubleshooting-ssl-problem-in-net-2-0-application.aspx
http://lextm.com
---------------------------
This posting is provided "AS IS" with no warranties, and confers no rights.
Alan-McG
1 Post
Re: Could not create SSL/TLS secure channel
Nov 16, 2009 01:36 AM|LINK
I am experiencing the exact same problem right now.. Did you manage to solve this?