Main Class – Where you are calling the Web Service, add following Import Statements
Imports System.Security.Cryptography.X509Certificates
Imports System.Net.Security
Imports System.Net
Public Class MyWebServiceCall
Public Sub CallServiceUsingFunction()
'Instanciate the Service here
'Set all paramaters which you need to pass
'Before You call the Service
ServicePointManager.ServerCertificateValidationCallback = AddressOf TrustAllCertificatesCallback
'Call your service Now.......
End Sub
Public Shared Function TrustAllCertificatesCallback(ByVal sender As Object, ByVal cert As X509Certificate, _
ByVal chain As X509Chain, ByVal errors As SslPolicyErrors) As Boolean
Return True
End Function
Public Sub CallServiceUsingClass()
'Instanciate the Service here
'Set all paramaters which you need to pass
'Before You call the Service
Dim CertOverride As New CertificateOverride
ServicePointManager.ServerCertificateValidationCallback = AddressOf CertOverride.RemoteCertificateValidationCallback
'Call your service Now.......
End Sub
End Class
CertificateOverride Class - An Alternate Option
Public Class CertificateOverride
Public Function RemoteCertificateValidationCallback(ByVal sender As Object, ByVal certificate As X509Certificate, ByVal chain As X509Chain, _
ByVal sslPolicyErrors As SslPolicyErrors) As Boolean
Return True
End Function
End Class