大家好我正在尝试访问启用了https / ssl的soap webservice。但是我收到了这个错误:
System.Net.WebException未处理
请求已中止:无法创建SSL / TLS安全通道。
以下是我用来打电话的代码。
Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim url As String = "https://10.31.171.199:8443/emc-dfs/services/core/ObjectService?WSDL"
System.Net.ServicePointManager.ServerCertificateValidationCallback = New System.Net.Security.RemoteCertificateValidationCallback(AddressOf ValidateRemoteCertificate)
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls Or SecurityProtocolType.Ssl3
Dim responsestring As String = ""
Dim myReq As HttpWebRequest = WebRequest.Create(url)
Dim proxy As IWebProxy = CType(myReq.Proxy, IWebProxy)
Dim proxyaddress As String
Dim myProxy As New WebProxy()
Dim response As String
myReq.AllowWriteStreamBuffering = False
myReq.Method = "GET"
myReq.ContentType = "application/soap+xml; charset=utf-8"
myReq.PreAuthenticate = True
proxyaddress = proxy.GetProxy(myReq.RequestUri).ToString
Dim newUri As New Uri(proxyaddress)
myProxy.Address = newUri
Dim myResponse As HttpWebResponse = myReq.GetResponse
Dim responsedata As Stream = myResponse.GetResponseStream
Dim responsereader As New StreamReader(responsedata)
response = responsereader.ReadToEnd
End Sub
我在线上收到此错误" Dim myResponse As HttpWebResponse = myReq.GetResponse "。
请帮我解决问题所在,如何拨打此服务。请帮助我使用SSL soap服务的任何工作示例代码。
感谢。
答案 0 :(得分:0)
如果服务器上的TLS不是 1.0,那么该版本可能?尝试:
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls Or SecurityProtocolType.Ssl3 Or SecurityProtocolType.Tls11 Or SecurityProtocolType.Tls12
除此之外,看看是否设置证书验证代理以绕过检查工作,即在调用请求方法之前:
ServicePointManager.ServerCertificateValidationCallback = Function() Return True