Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/291.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# WCF客户端绑定以访问https服务。无法为具有权限的SSL/TLS建立安全通道_C#_Wcf_Ssl_Https_Wcf Binding - Fatal编程技术网

C# WCF客户端绑定以访问https服务。无法为具有权限的SSL/TLS建立安全通道

C# WCF客户端绑定以访问https服务。无法为具有权限的SSL/TLS建立安全通道,c#,wcf,ssl,https,wcf-binding,C#,Wcf,Ssl,Https,Wcf Binding,我需要创建WCF客户端来连接通过https提供的服务。 负责WCF的当前客户端配置如下所示: <wsHttpBinding> <binding name="TestBinding"> <security mode="Transport"> <transport clientCredentialType="None" /> </security> </binding> </wsHt

我需要创建WCF客户端来连接通过https提供的服务。 负责WCF的当前客户端配置如下所示:

<wsHttpBinding>
  <binding name="TestBinding">
    <security mode="Transport">
        <transport clientCredentialType="None" />
    </security>
  </binding>
</wsHttpBinding>
<client>
   <endpoint address="https://address/etc" binding="wsHttpBinding" bindingConfiguration="TestBinding" contract="TestService.Test" name="TestName"/>
</client>
我没有权限修改此服务

更新:

出于测试目的,我忽略了Application_Start中global.asax中的证书,但仍然得到了相同的异常

protected void Application_Start(object sender, EventArgs e) {
   ServicePointManager.ServerCertificateValidationCallback = delegate { return true; };
}

不受信任的证书可能导致此问题。 请在呼叫您的服务前尝试以下操作:

protected void BypassCertificateError()
{
    ServicePointManager.ServerCertificateValidationCallback = delegate (object sender, X509Certificate certificate, X509Chain chain, SslPolicyErrors sslPolicyErrors) { return true; };
}

但是请注意,这不是一个好的做法,因为它完全忽略了服务器证书。

不受信任的证书可能会导致这种情况。 请在呼叫您的服务前尝试以下操作:

protected void BypassCertificateError()
{
    ServicePointManager.ServerCertificateValidationCallback = delegate (object sender, X509Certificate certificate, X509Chain chain, SslPolicyErrors sslPolicyErrors) { return true; };
}

但是请注意,这不是一个好的做法,因为它完全忽略了服务器证书。

在调用之前,我有过这种情况,我在ApplicationStart中也有过,但仍然得到相同的异常。ServicePointManager.ServerCertificateValidationCallback=委托{return true;};您可能正在使用WCFTestClient。不幸的是,WCFTestClient不支持不受信任的证书。您可以使用SOAPUI来测试您的服务。我使用的是来自代码的客户端。它由AddServiceReference生成。它不是wcftestclient如果它是公共web服务,请提供调用您的服务所需的信息。我希望我能帮助你。不幸的是,这项服务只在我的公司内部提供。在打电话之前,我有过这项服务,我在ApplicationStart中也有过,但仍然得到同样的例外。ServicePointManager.ServerCertificateValidationCallback=委托{return true;};您可能正在使用WCFTestClient。不幸的是,WCFTestClient不支持不受信任的证书。您可以使用SOAPUI来测试您的服务。我使用的是来自代码的客户端。它由AddServiceReference生成。它不是wcftestclient如果它是公共web服务,请提供调用您的服务所需的信息。我希望我能帮助你。不幸的是,这项服务只在我公司内部提供