Web services 在https中调用WebService

Web services 在https中调用WebService,web-services,https,web-config,Web Services,Https,Web Config,我创建了一个Web服务来生成pdf文件。在VisualStudio 2012的调试模式下。没关系。我可以从其他Intranet站点调用它 我试着把它放在我的测试服务器上。但是我需要添加https而不是http 我发现 我试着像这样适应我的web.config <system.serviceModel> <bindings> <basicHttpBinding> <binding name="GenerationCourriersSoap"

我创建了一个Web服务来生成pdf文件。在VisualStudio 2012的调试模式下。没关系。我可以从其他Intranet站点调用它

我试着把它放在我的测试服务器上。但是我需要添加https而不是http

我发现 我试着像这样适应我的web.config

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

但我有个口信

无法为授权为“localhost:52999”的安全通道SSL/TLS建立信任

我使用了IIS直接创建的自动认证。 我确认,此证书位于我的根目录和安全文件夹中 有人有主意吗?

我终于找到了这个

看起来不错。现在我可以访问Web服务了

其想法是强制验证所有证书。就是这样的考试时间

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
并在调用WebService函数之前调用函数

ServicePointManager.ServerCertificateValidationCallback = AddressOf AcceptAllCertifications