I got this error when calling a WCF Service over HTTPS. A Similar error can also occurs when you try calling a web service programmatically over SSL (HTTPS) and certificate is either not valid or Certificate is attached to a domain and you are not using the domain name but the machine name or IP address. So, what to do in that case if you don’t care about certificate and would like to accept all certificates. I found that it can be done using one of two ways.
Main Class – Where you are calling the Web Service, add following Import StatementsImports System.Security.Cryptography.X509CertificatesImports System.Net.SecurityImports System.NetPublic Class MyWebServiceCallPublic Sub CallServiceUsingFunction()'Instanciate the Service here'Set all paramaters which you need to pass'Before You call the ServiceServicePointManager.ServerCertificateValidationCallback = AddressOf TrustAllCertificatesCallback'Call your service Now.......End SubPublic Shared Function TrustAllCertificatesCallback(ByVal sender As Object, ByVal cert As X509Certificate, _ByVal chain As X509Chain, ByVal errors As SslPolicyErrors) As BooleanReturn TrueEnd FunctionPublic Sub CallServiceUsingClass()'Instanciate the Service here'Set all paramaters which you need to pass'Before You call the ServiceDim CertOverride As New CertificateOverrideServicePointManager.ServerCertificateValidationCallback = AddressOf CertOverride.RemoteCertificateValidationCallback'Call your service Now.......End SubEnd ClassCertificateOverride Class - An Alternate OptionPublic Class CertificateOverridePublic Function RemoteCertificateValidationCallback(ByVal sender As Object, ByVal certificate As X509Certificate, ByVal chain As X509Chain, _ByVal sslPolicyErrors As SslPolicyErrors) As BooleanReturn TrueEnd FunctionEnd Class
5 comments:
Can anyone recommend the best Network Monitoring program for a small IT service company like mine? Does anyone use Kaseya.com or GFI.com? How do they compare to these guys I found recently: N-able N-central remote environment manager
? What is your best take in cost vs performance among those three? I need a good advice please... Thanks in advance!
Please, can you PM me and tell me few more thinks about this, I am really fan of your blog...
I would personally just renew my ssl cert and this shouldnt happen in future!
Well... that's quiet interessting but frankly i have a hard time visualizing it... wonder how others think about this..
Dealer’s Choice Inc. (DCI), began in 1990 providing services and partnering with automobile dealerships to maintain customer loyalty and enhance profitability. DCI provides auto dealers with tools and products that enable them to stay in touch with their customer base while providing quality Finance and Insurance products to increase their profit marginService ContractsOur Dealer clients maintain their ongoing relationship with Dealer’s Choice, Inc. because at DCI we view each Dealer customer as if they are our own...
Post a Comment