我们正在设置一个新的 SharePoint,我们还没有有效的 SSL 证书。我想调用其上的列表 Web 服务来检索有关设置的一些元数据。但是,当我尝试这样做时,出现异常:
The underlying connection was closed: Could not establish trust relationship for the SSL/TLS secure channel.
嵌套异常包含错误信息:
The remote certificate is invalid according to the validation procedure.
这是正确的,因为我们使用的是临时证书。
我的问题是:如何告诉 .Net Web 服务客户端 (SoapHttpClientProtocol) 忽略这些错误?
最佳答案
或者,您可以注册一个忽略认证错误的回调委托(delegate):
...
ServicePointManager.ServerCertificateValidationCallback = MyCertHandler;
...
static bool MyCertHandler(object sender, X509Certificate certificate, X509Chain chain, SslPolicyErrors error)
{
// Ignore errors
return true;
}
关于.net - 在 .Net 中调用 Web 服务时绕过无效的 SSL 证书错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32393623/