【发布时间】:2018-05-29 20:54:06
【问题描述】:
从今天开始,我在发送包裹时收到以下错误消息:
Error calling Login: The request was aborted: Could not create SSL/TLS secure channel.
我的代码
StringBuilder authHeader = new StringBuilder(
$"{{\"Username\":\"{userId}\", \"Password\":\"" +
$"{password}\", \"IntegratorKey\":\"{IntegratorKey}\"");
authHeader.Append(
string.IsNullOrEmpty(senderEmail)
? "}}"
: $",\"SendOnBehalfOf\": \"{senderEmail}\"}}");
Configuration.Default.AddDefaultHeader(
"X-DocuSign-Authentication",
authHeader.ToString());
AuthenticationApi api = new AuthenticationApi();
return api.Login();
巧合的是,今天是在 DocuSign 演示站点上禁用 TLS1.0 的日子。 (source) 虽然我知道这一点,但我的应用程序使用 .NET 4.7 框架,默认情况下将使用 TLS1.2。因此,这应该不是问题 当我使用找到 here 的 DocuSign NuGet 包时,我查看了源代码,它使用 .NET 4.5(除非另有说明,否则它使用 TLS1.0)
我知道我可以实现 this solution 但是,由于我的应用程序使用 .NET 4.7,它不应该工作吗?
【问题讨论】:
-
我认为社区无法帮助您。看来您需要等到该库更新
-
当然,但我原以为 DocuSign 会在删除 TLS1.0 支持之前升级库,至少这对我来说是有意义的......
-
.Net 4.7 提供的 TLS 选项是一回事。
ServicePointManager默认是另一个。ServicePointManager(最高 .Net 4.7.1)协商 SSL3 和 TLS 1.0。如果要确保协商 TLS 1.2,则必须显式启用协议(不包括进程中的其他协议,设置ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12)。然后,它取决于服务器可以在握手中达成什么协议。但是如果不启用TLS1.2,就不会协商。 -
我忘了说,你可以用这个来检查什么 SSL 协议版本:Which TLS version was negotiated?
-
@Jimi:谢谢,但如果你没有注意到,我是最初提出这个问题的人“协商了哪个 Tls 版本”,所以我知道这一点。仅当我要修改我不感兴趣的 DocuSign SDK 时,答案才有效,因为我想使用官方的
标签: c# docusignapi