禁用已过时的tls

This commit is contained in:
陈国伟 2021-08-30 11:06:22 +08:00
parent c5b2bfb579
commit 3c1ceba49e

View File

@ -8,6 +8,7 @@ using System.Net;
using System.Net.Http; using System.Net.Http;
using System.Net.Security; using System.Net.Security;
using System.Net.Sockets; using System.Net.Sockets;
using System.Security.Authentication;
using System.Security.Cryptography.X509Certificates; using System.Security.Cryptography.X509Certificates;
using System.Threading; using System.Threading;
using System.Threading.Tasks; using System.Threading.Tasks;
@ -172,6 +173,7 @@ namespace FastGithub.Http
var sslStream = new SslStream(stream, leaveInnerStreamOpen: false); var sslStream = new SslStream(stream, leaveInnerStreamOpen: false);
await sslStream.AuthenticateAsClientAsync(new SslClientAuthenticationOptions await sslStream.AuthenticateAsClientAsync(new SslClientAuthenticationOptions
{ {
EnabledSslProtocols = SslProtocols.Tls12 | SslProtocols.Tls13,
TargetHost = requestContext.TlsSniPattern.Value, TargetHost = requestContext.TlsSniPattern.Value,
RemoteCertificateValidationCallback = ValidateServerCertificate RemoteCertificateValidationCallback = ValidateServerCertificate
}, cancellationToken); }, cancellationToken);