我制作了一个应该接受SSL连接的程序。我希望它只接受TLS 1.2以提高安全性。无法在C#中使用SslStream接受TLS 1.2协议和.net框架4.6
要做到这一点,我已经安装了.NET Framework 4.6,并在Windows 7 Professional SP1电脑上使用Visual Studio 2015 express编译了SW。在VS下的“应用程序”目标框架已被设为4.6
在SW I使用SslStream方法来验证该证书,以确保只有TLS 1.2时,我输入线
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12
我试着插入这条线都在main()
,只是做一个新的SSL流
为了测试我使用OpenSSL连接之前,用命令:
openssl s_client -connect 10.0.0.101:1400 -tls1_2 -cert MyCert.pem -key private.pem -CAfile entrust.cer
我的问题是,C#程序得到以下异常:从OpenSSL的
Exception: A call to SSPI failed, see inner exception.
Inner exception: The function requested is not supported
输出是
CONNECTED(00000150) 7964:error:1408F10B:SSL routines:SSL3_GET_RECORD:wrong version number:.\ssl\s3_pkt.c:362:
no peer certificate available
No client certificate CA names sent
SSLL handshake has read 5 bytes and written 7 bytes
New, (NONE), Cipher is (NONE) Secure Renegotiation IS NOT supported Compression: NONE Expansion: NONE No ALPN negotiated SSL-Session: Protocol : TLSv1.2 Cipher : 0000 Session-ID: Session-ID-ctx: Master-Key: Key-Arg : None PSK identity: None PSK identity hint: None SRP username: None Start Time: 1457011106 Timeout : 7200 (sec) Verify return code: 0 (ok)
如果我使用-tls1是没有问题的,所以我认为这是因为。净SslStream不支持tls1_2(或tls1_1)
是否有任何人能解释一下我做错了
/卡斯滕
一段时间后,我发现,TLS 1.1和1.2默认情况下不会在Win 7 enabeled。 MS在[TLS/SSL设置](https://technet.microsoft.com/en-us/library/dn786418.aspx)中给出了一个指导如何通过通过regedit进行更改来启用它。我现在的问题是,当查看HKEY_LOCAL_MASCHINE \ SYSTEM \ CurrentControlSet \ Control \ SecurityProviders \ SCHANNEL \ Protocols时,我只有一个SSL 2.0条目,但如前所述,它在SSL3/TLS1.0上工作。我是否必须在法规中进行更改?数据库? –
我对openssl不熟悉,也没有在监听模式下使用SslStream,所以我无法直接回答你的问题。但是,我知道我的Windows 7支持TLS协议1.0,1.1和1.2。 SCHANNEL上的注册表项可用于禁用特定协议,但其默认状态已启用。您不应该更改注册表才能使其发挥作用。 –
嗨..好吧...这是我不明白的事情之一...我可以连接到TLS 1.2到浏览器等,但如果我尝试连接到TLS 1.2的控制台应用程序,我被拒绝上面的描述,即使我在属性中使用框架4.6,并在安全协议标志中设置TLS 1.2标志.... –