我使用以下代码进行证书验证。
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。如何解决它。
答案 0 :(得分:1)
您的回调并未执行与系统默认验证不同的任何操作。 sslPolicyErrors的值将指示失败是什么,并且您可以查询证书,链和发送方的属性,以决定是否要通过返回true来覆盖失败。