首页 文章

忽略Web服务中的证书错误?

提问于
浏览
1

有没有办法忽略SSL证书错误?

我已经开发了一个Web服务,到目前为止一直使用http在本地运行,但是它已经被外部移动并需要通过https进行通信 . 用于测试目的的证书是自签名的,因此不受信任,我收到错误 The provided URI scheme 'https' is invalid; expected 'http'.

Web.config

<system.serviceModel>
    <bindings>
        <basicHttpBinding>
            <binding name="RemoteSoap" />
        </basicHttpBinding>
    </bindings>
    <client>
        <endpoint address="https://mydomainwebservice:8444/Test.asmx" binding="basicHttpBinding"
    bindingConfiguration="RemoteSoap" contract="RemoteService.RemoteSoap"
    name="RemoteSoap" />
   </client>
</system.serviceModel>

如果我添加以下安全元素,则会出现以下错误 The remote certificate is invalid according to the validation procedure. ,这似乎是由 The underlying connection was closed: Could not establish trust relationship for the SSL/TLS secure channel. 引起的

<security mode="Transport">
    <transport clientCredentialType="None" />
</security>

有人可以建议忽略这些错误吗?

1 回答

  • 2

    尝试编辑.config中的配置值

    <configuration>
     <system.net>
      <settings>
        <servicePointManager
          checkCertificateName="false"
          checkCertificateRevocationList="false"      
        />
      </settings>
     </system.net>
    </configuration>
    

相关问题