
The solution. First we have to create a class that will override CheckValidationResult function of System.Security.Cryptography.X509Certificates; Here's the custom code of the class I created:
Imports System.Net
Imports System.Security.Cryptography.X509Certificates
Public Class MyPolicy
Implements ICertificatePolicy
Public Function CheckValidationResult(ByVal srvPoint As ServicePoint, _
ByVal cert As X509Certificate, ByVal request As WebRequest, _
ByVal certificateProblem As Integer) _
As Boolean Implements ICertificatePolicy.CheckValidationResult
'Return True to force the certificate to be accepted.
Return True
End Function
End Class
Then you can call the class anywhere before you execute the web service.
System.Net.ServicePointManager.CertificatePolicy = New MyPolicy
'Call web service here
Summary. On this solution we override the CheckValidationResult function of System.Net.ServicePointManager.CertificatePolicy class to create a custom one that will accept all security certificate automatically. You can also implement this solution to any .NET languages like C# and C++
Now were done. Happy Coding to all!
10 comments:
Just what I need! Five (5) star for you!
Nice tip. Just wondering if you have VB .NET code to connect to web service that requires Proxy authentication. Please email it to me @ fklumbao@gmail.com
Hallo thanks for this Code.
Its Great for my VBNET Code through an Proxy and helps.
Thomas
thats a nice tip.. this is exactly what I was looking for.
thanks.
Nitin
Awesome man! You saved me a ton of time.
Thank You!
That's a realy great small Tip!
Salut
Marcel
Thanks a Lot... You saved my lot time...
Yassar
I am trying to call a Secured Web Service which requires Soap/HTTP header authentication. Can you please send me the VB.Net code to kcsr116@yahoo.com
Thanks!
This was what I needed. Searched a lot for it. Thanx
Thank you very much! Just what I need.
Post a Comment