How to create SSLStream which uses Ssl3 instead of

2019-08-09 11:59发布

问题:

I'm trying to establish tcp connection which is encrypted using Ssl3.

Basically I'm just creating TCP connection and than I'm creating SSLStream on top of that:

var ss = new SslStream(poolItem.SecureConnection, false, remoteCertificateValidationCallback);

ss.ReadTimeout = ss.WriteTimeout = timeout;

ss.AuthenticateAsClient(host);

var pp = ss.SslProtocol;

My problem is that by default SslStream uses TLS. I want for it to be Ssl3.

In HttpWebRequest, you can use following code to change the protocol:

ServicePointManager.SecurityProtocol = SecurityProtocolType.Ssl3;

I checked it, and it doesn't affect SslStream.

How do I change SslStream's protocol to Ssl3?

回答1:

You just have to use the AuthenticateAsClient overload that lets you specify which protocols should be allowed:

AuthenticateAsClient
  (host, new X509CertificateCollection(), SslProtocols.Ssl3, false);