加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 大数据 > 正文

VB .net接受自签名SSL证书

发布时间:2020-12-17 00:07:02 所属栏目:大数据 来源:网络整理
导读:我正在寻找一种使用VB .NET来验证(或绕过验证)自签名SSL证书的方式.我在C#中找到了这样的代码,并尝试将其转换为VB代码,但我没有任何运气. 这是C# code. 这是我试过的: Imports SystemImports System.NetImports System.Security.Cryptography.X509Certifica
我正在寻找一种使用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

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读