gpt4 book ai didi

c# - 错误 : The underlying connection was closed: Could not establish trust relationship for the SSL/TLS secure channel

转载 作者:太空宇宙 更新时间:2023-11-03 14:52:51 26 4
gpt4 key购买 nike

我有使用网络服务的工具。我已经为 Web 服务生成了一个自签名证书,并使用证书管理器将其导出到本地路径。

我正在按照以下 msdn 代码将证书添加到 web 服务中。 https://support.microsoft.com/en-us/kb/901183

string certPath = @"C:\TestData\certificate.cer";
test.ClientCertificates.Add(X509Certificate.CreateFromCertFile(certPath));

上面是我的代码。

我收到以下错误。

The underlying connection was closed: Could not establish trust relationship for the SSL/TLS secure channel.

堆栈跟踪:

at System.Web.Services.Protocols.WebClientProtocol.GetWebResponse(WebRequest request)
at System.Web.Services.Protocols.HttpWebClientProtocol.GetWebResponse(WebRequest request)
at System.Web.Services.Protocols.SoapHttpClientProtocol.Invoke(String methodName, Object[] parameters)
at web_Client.testClient.testClassWebService.Add(Request request) in C:\Workspace\Reference.cs:line 248
at web_Client.WebClient.Add() in C:\Workspace\WebClient.cs:line 227

我不知道发生了什么。我对网络和证书很陌生。请帮忙。

最佳答案

在过去的几天里,我遇到了一个以前运行良好的应用程序。我认为拥有服务器的人更新了一些东西,现在他们需要一个不同的协议(protocol)。我只是通过迁移到更高版本的框架来解决其中一个问题。对于第二个,我不得不转到更高版本 (4.5) 并将 ServicePointManager.SecurityProtocol 设置为不同的协议(protocol)。您可以使用智能感知来查看您的选项。

关于c# - 错误 : The underlying connection was closed: Could not establish trust relationship for the SSL/TLS secure channel,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32608795/

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