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

时间:2014-06-26 09:06:03

标签: c# web-services wcf ssl

有没有办法忽略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 个答案:

答案 0 :(得分:3)

尝试编辑.config

中的配置值
<configuration>
 <system.net>
  <settings>
    <servicePointManager
      checkCertificateName="false"
      checkCertificateRevocationList="false"      
    />
  </settings>
 </system.net>
</configuration>