c# - 指定用于 WSHttpBinding 客户端连接的 SSL 协议(protocol)版本

标签 c# .net ssl client-certificates

在通过 WSHttpBinding 使用 Web 服务时,是否可以指定要使用的 SSL 协议(protocol)版本?

我一直在使用跟踪日志来尝试确定为什么我使用客户端证书通过 SSL 调用 Web 服务失败。

最终日志记录显示警报 15 03 01 00 02 和警报代码 02 0A,这是一个 unexpected_error。我怀疑此错误是因为服务器无法处理我向其发送的 SSL 版本。

System.Net.Sockets Verbose: 0 : [13908] Exiting Socket#15927457::Send()     -> Int32#138
System.Net.Sockets Verbose: 0 : [13908] Socket#15927457::Receive()
System.Net.Sockets Verbose: 0 : [13908] Data from Socket#15927457::Receive
System.Net.Sockets Verbose: 0 : [13908] 00000000 : 15 03 01 00 02                                  : .....
System.Net.Sockets Verbose: 0 : [13908] Exiting Socket#15927457::Receive()  -> Int32#5
System.Net.Sockets Verbose: 0 : [13908] Socket#15927457::Receive()
System.Net.Sockets Verbose: 0 : [13908] Data from Socket#15927457::Receive
System.Net.Sockets Verbose: 0 : [13908] 00000005 : 02 0A                                           : ..
System.Net.Sockets Verbose: 0 : [13908] Exiting Socket#15927457::Receive()  -> Int32#2
System.Net Information: 0 : [13908] InitializeSecurityContext(credential = System.Net.SafeFreeCredential_SECURITY, context = 79d80e8:7a0e230, targetName = dsl-wholesale-testing.iinet.net.au, inFlags = ReplayDetect, SequenceDetect, Confidentiality, AllocateMemory, InitManualCredValidation)
System.Net Information: 0 : [13908] InitializeSecurityContext(In-Buffers count=2, Out-Buffer length=0, returned code=IllegalMessage).
System.Net.Sockets Verbose: 0 : [13908] Socket#15927457::Dispose()
System.Net Error: 0 : [13908] Exception in HttpWebRequest#41613110:: - The request was aborted: Could not create SSL/TLS secure channel..
System.Net Error: 0 : [13908] Exception in HttpWebRequest#41613110::GetResponse - The request was aborted: Could not create SSL/TLS secure channel..

我有一个基于 PHP 的客户端,它使用相同的网络服务,我通过 cURL 指定 SSL 版本 3 (curl_setopt($ch, CURLOPT_SSLVERSION, 3);)。

最佳答案

版本可以设置如下:

System.Net.ServicePointManager.SecurityProtocol = System.Net.SecurityProtocolType.Ssl3;

关于c# - 指定用于 WSHttpBinding 客户端连接的 SSL 协议(protocol)版本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18141990/

相关文章:

ssl - 使用 let's encrypt 在 lamp web 服务器 ec2 aws 上配置 https

apache - .htaccess 基于SSL协议(protocol)的重定向

c# - 使用 XmlSerializer 将 DataTable 反序列化为自定义类

c# - 从 JSON 输出中删除不需要的空格

c# - Visual Studio 智能感知搞砸了

c# - 在 C# 中强制命名参数

.net - WCF::ServiceHost: Oddity...即使线程死了还活着吗?

c# - httpHandler Content-Length 太短?

php添加SSL证书

c# - 如何使用 for 循环迭代链接 IEnumerable.Where()?