VB .net Accept Self-Signed SSL certificate

后端 未结 4 1842
不思量自难忘°
不思量自难忘° 2021-01-01 14:50

I\'m searching for a way to validate (or bypass validation for) self-signed SSL certificates using VB .Net. I found code to do this in C# and tried converting it into VB co

相关标签:
4条回答
  • 2021-01-01 15:16

    One-liner:

    System.Net.ServicePointManager.ServerCertificateValidationCallback = _
      Function(se As Object, _
      cert As System.Security.Cryptography.X509Certificates.X509Certificate, _
      chain As System.Security.Cryptography.X509Certificates.X509Chain, _
      sslerror As System.Net.Security.SslPolicyErrors) True
    

    Credits to Robby Tendean

    0 讨论(0)
  • 2021-01-01 15:16

    I'm not sure but this should work:

    ServicePointManager.ServerCertificateValidationCallback = _
          New RemoteCertificateValidationCallback(AddressOf AcceptAllCertifications)
    

    http://msdn.microsoft.com/de-de/library/system.net.security.remotecertificatevalidationcallback%28VS.90%29.aspx

    0 讨论(0)
  • 2021-01-01 15:16

    In VB.Net,

    ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls
    

    solves the less secure apps problem.

    0 讨论(0)
  • 2021-01-01 15:40

    In VB.Net, you need to write

    ServicePointManager.ServerCertificateValidationCallback = AddressOf AcceptAllCertifications
    
    0 讨论(0)
提交回复
热议问题