gpt4 book ai didi

c# - "could not establish secure channel for ssl/tls with authority"在特定服务器上调用 WCF 服务时

转载 作者:太空宇宙 更新时间:2023-11-03 13:59:20 24 4
gpt4 key购买 nike

我们围绕 WCF API 服务进行了一些自动化测试,但我们希望能够在使用新服务器之前快速测试添加到我们生产场的新服务器。我们目前以这种方式调用 ApiService:

using (var wcfApiServiceClient = new ApiServiceClient())
{
WcfResponse = wcfApiServiceClient.Request(request);
}

但请求失败并显示消息 Could not establish trust relationship for the SSL/TLS secure channel with authority 'servername:12345'. 当我尝试在浏览器中查看 wsdl 时,我得到一个不受信任的证书警告,所以我想这是我的问题。我在我的 app.config 中尝试了这些东西:

<endpoint ... bindingConfiguration="BasicHttpBinding_IApiService"  
behaviorConfiguration="DisableServiceCertificateValidation" />
<behaviors>
<endpointBehaviors>
<behavior name="DisableServiceCertificateValidation">
<clientCredentials>
<serviceCertificate>
<authentication certificateValidationMode="None"
revocationMode="NoCheck" />
</serviceCertificate>
</clientCredentials>
</behavior>
</endpointBehaviors>
</behaviors>

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

<basicHttpBinding>
<binding name="BasicHttpBinding_IApiService">
<security mode="Transport" >
<transport clientCredentialType="None" proxyCredentialType="None" />
</security>
</binding>
</basicHttpBinding>

我无法更改服务器上的任何内容,但是在使用 .net 调用 WCF 服务时是否有某种方法可以忽略 ssl 错误?谢谢!

最佳答案

当您的 Api 客户端连接到服务器时,服务器正在发回证书,在这种情况下,该证书是不受信任的 => 握手失败。我还会尝试从浏览器下载证书,并使用 Windows mmc.exe 工具将其导入客户端计算机的根证书颁发机构。

希望这有帮助:)

关于c# - "could not establish secure channel for ssl/tls with authority"在特定服务器上调用 WCF 服务时,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55543001/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com