.net - 在 .Net 中调用 Web 服务时绕过无效的 SSL 证书错误

标签 .net web-services sharepoint

我们正在设置一个新的 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/

相关文章:

c# - 你能帮我优化这段代码来查找数字的因子吗?我正在温习数学编程

c# - 用于视频播放的 .NET FFmpeg 包装器

android - 带回调的通用 asyncTask(用于 Web 服务)

Sharepoint 权限(用户应该能够提交表单,但不能编辑/删除它)?

如果没有前任匹配类,则 jQuery 选择

c# - .NET SoundPlayer问题

c# - 继承一个已经实例化的基础对象

php - 如何在php中使用base64binary

c# - 报告服务 2008 : "HTTP status 401: Unauthorized" Issue

web-services - 通过 List Webservice 更新列表项来触发 SharePoint 工作流