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 (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
推荐文章
站长推荐
- 从 Delphi 7 升级到 Delphi 2010 基本数据类型的
- 【转】浅析Lua中table的遍历 by rangercyh
- ToLua学习笔记(九) Example 09 Dictionary
- 详细Laravel5.5执行表迁移命令出现表为空的解决方
- java – Spring-Batch代理类不能转换为Class?
- delphi – 为什么ShowModal正在锁定Synchronize?
- FP-Tree思想与实现
- vb.net 实现u盘插入,拔出的识别
- IntelliJ IDEA 创建spring boot 的Hello World 项
- Beginning Perl for Bioinformatics 总结提升
热点阅读