未能为 SSL/TLS 安全通道建立信任的解决办法

1:先加入命名空间

Imports System.Net.Security
Imports System.Security.Authentication
Imports System.Security.Cryptography.X509Certificates

2:再重载CheckValidationResult方法,返回true

    Public Function CheckValidationResult(sender As Object, certificate As X509Certificate, chain As X509Chain, errors As SslPolicyErrors) As Boolean
        '总是接受
        Return True
    End Function

3:然后在Dim reqGet As HttpWebRequest = WebRequest.Create(URL)前面加上如下一行代码

ServicePointManager.ServerCertificateValidationCallback = New System.Net.Security.RemoteCertificateValidationCallback(AddressOf CheckValidationResult)

 

posted on 2013-01-04 17:00  Konimeter  阅读(3301)  评论(0编辑  收藏  举报