VB .net接受自签名SSL证书

前端之家收集整理的这篇文章主要介绍了VB .net接受自签名SSL证书前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我正在寻找一种使用VB .NET来验证(或绕过验证)自签名SSL证书的方式.我在C#中找到了这样的代码,并尝试将其转换为VB代码,但我没有任何运气.

这是C# code.

这是我试过的:

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

Public Class clsSSL
    Public Function AcceptAllCertifications(ByVal sender As Object,ByVal certification As System.Security.Cryptography.X509Certificates.X509Certificate,ByVal chain As System.Security.Cryptography.X509Certificates.X509Chain,ByVal sslPolicyErrors As System.Net.Security.SslPolicyErrors) As Boolean
        Return True
    End Function
End Class

然后在Webrequest之前我有这行代码给我一个错误.

ServicePointManager.ServerCertificateValidationCallback = New System.Net.Security.RemoteCertificateValidationCallback(AcceptAllCertifications)

错误信息是:

Delegate 'System.Net.Security.RemoteCertificateValidationCallback' requires an 'AddressOf' expression or lambda expression as the only argument to its constructor.
在VB.Net中,你需要写
ServicePointManager.ServerCertificateValidationCallback = AddressOf AcceptAllCertifications

猜你在找的VB相关文章