【问题标题】:Call WebService in https在 https 中调用 WebService
【发布时间】:2016-02-08 18:57:43
【问题描述】:

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

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

我找到this 我尝试像这样适应我的 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-services https web-config


    【解决方案1】:

    终于找到了enter link description here

    看起来不错。现在我可以访问 webService。

    这个想法是强制验证所有证书。就是这样的测试期时间

    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
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2015-11-13
      • 1970-01-01
      • 2011-03-30
      • 2017-06-13
      • 2011-05-05
      • 1970-01-01
      • 1970-01-01
      • 2012-02-11
      相关资源
      最近更新 更多