The underlying connection was closed: Could not establish se
I am trying to download a file from a website over SSL. Below is the code snippet. This website prompts for a certificate. I am adding the certificate to the request object from a .cer file. Wondering what is the problem. Also tried skipping the certificate using the interface Icertificate policy.
Exception is :-
System.Net.WebException: The underlying connection was closed: Could
not establish secure channel for SSL/TLS. ---System.Net.WebException:
The request was aborted: The connection was closed unexpectedly.
Dim Req As HttpWebRequest =
Req.Method = "POST"
Req.AllowAutoRedirect = True
Req.Proxy = System.Net.WebProxy.GetDefaultProxy()
Req.Timeout = 100000
Req.ProtocolVersion = HttpVersion.Version11
Req.ContentType = "text/xml"
Req.KeepAlive = False
postdata = ""
Req.ContentLength = postdata.Length
Req.AllowWriteStreamBuffering = True
Dim result As String
Dim objResponse As HttpWebResponse = Req.GetResponse()
Dim sr As StreamReader
sr = New StreamReader(objResponse.GetResponseStream())
result = sr.ReadToEnd
Tags for this Thread