我正在寻找一种使用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
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