1

我正在使用以下代码进行证书验证。

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

Public Shared Function ValidateServerCertificate(ByVal sender As Object, ByVal certificate As X509Certificate, ByVal chain As X509Chain, ByVal sslPolicyErrors As Net.Security.SslPolicyErrors) As Boolean
    If sslPolicyErrors = Net.Security.SslPolicyErrors.None Then
        Return True
    End If
    Return False
End Function

我收到 RemoteCertificateChainErrors。如何解决它。

4

1 回答 1

1

您的回调与系统默认验证没有任何不同。sslPolicyErrors 的值将指示失败是什么,您可以查询证书、链和发送者的属性,以决定是否要通过返回 true 来覆盖失败。

于 2015-09-25T04:51:20.140 回答