Home Ask Login Register

Developers Planet

Your answer is one click away!

YannickIngenierie February 2016

Call WebService in https

I create a webService to generate pdf file. In debug mode with VisualStudio 2012. It's Ok. I can call it from other IntranetSite.

I try to put it on my test server. But I need to add https instead of http.

I find this I try to adapted like this my web.config

      <binding name="GenerationCourriersSoap" >
          <security mode="Transport">
              <transport clientCredentialType="None" proxyCredentialType="None" realm="" />
              <message clientCredentialType="Certificate" algorithmSuite="Default" />
<behavior name="secureBehaviours">
  <serviceMetadata httpsGetEnabled="true"/>
<endpoint address="https://localhost:52999/GenerationCourrier.asmx"
binding="basicHttpBinding" bindingConfiguration="GenerationCourriersSoap"
contract="WSCourrier.GenerationCourriersSoap" name="GenerationCourriersSoap"    />

But I've message

Unable to establish a trust for the secure channel SSL / TLS with authority 'localhost: 52999'.

I used an auto-certicate buid by IIS directly. I verify, this certificate is on my root and secure folder Someone have an idea?


YannickIngenierie March 2016

Finally I find this enter link description here

It seems good. now I can reach the webService.

The Idea is to force the validation of all certificate. Just the time of test period like that

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

And call function just before call WebService function

ServicePointManager.ServerCertificateValidationCallback = AddressOf AcceptAllCertifications

Post Status

Asked in February 2016
Viewed 2,870 times
Voted 14
Answered 1 times


Leave an answer

Quote of the day: live life