I keep getting the following error message when trying to make an SSL Connection via VB.NET's WebRequest:
The underlying connection was closed: Could not establish trust relationship with remote server.
VB Code:
Private Function SendXML(ByVal xml As String) As String Dim aURL As String aURL = "https://www.site.com:10027" Dim wr As HttpWebRequest = Net.WebRequest.Create(aURL) Dim cert As System.Security.Cryptography.X509Certificates.X509Certificate cert = System.Security.Cryptography.X509Certificates.X509Certificate.CreateFromSignedFile("C:\cert\ca.cer") wr.ClientCertificates.Add(cert) wr.ContentType = "text/xml" wr.KeepAlive = False wr.Method = "POST" Dim sw As StreamWriter Try sw = New StreamWriter(wr.GetRequestStream()) sw.Flush() sw.AutoFlush = True Catch ex As Exception Return False End Try Try sw.Write(xml) sw.Flush() sw.Close() Catch ex As Exception Return False End Try wr.Timeout = 900000 Dim wres As HttpWebResponse = wr.GetResponse Dim s As IO.Stream s = wres.GetResponseStream Dim sr As IO.StreamReader sr = New IO.StreamReader(s) Return sr.ReadToEnd End Function




Reply With Quote