Skip to content

Commit a50f94e

Browse files
authored
Use default SslProtocols in Kestrel (#22437)
1 parent e271b83 commit a50f94e

File tree

5 files changed

+13
-4
lines changed

5 files changed

+13
-4
lines changed

src/Servers/Kestrel/Core/src/CoreStrings.resx

+3
Original file line numberDiff line numberDiff line change
@@ -602,4 +602,7 @@ For more information on configuring HTTPS see https://go.microsoft.com/fwlink/?l
602602
<data name="GreaterThanOrEqualToZeroRequired" xml:space="preserve">
603603
<value>A value greater than or equal to zero is required.</value>
604604
</data>
605+
<data name="HttpsConnectionEstablished" xml:space="preserve">
606+
<value>Connection "{connectionId}" established using the following protocol: {protocol}</value>
607+
</data>
605608
</root>

src/Servers/Kestrel/Core/src/HttpsConnectionAdapterOptions.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ public class HttpsConnectionAdapterOptions
2424
public HttpsConnectionAdapterOptions()
2525
{
2626
ClientCertificateMode = ClientCertificateMode.NoCertificate;
27-
SslProtocols = SslProtocols.Tls12 | SslProtocols.Tls11;
2827
HandshakeTimeout = TimeSpan.FromSeconds(10);
2928
}
3029

@@ -61,7 +60,8 @@ public HttpsConnectionAdapterOptions()
6160
public Func<X509Certificate2, X509Chain, SslPolicyErrors, bool> ClientCertificateValidation { get; set; }
6261

6362
/// <summary>
64-
/// Specifies allowable SSL protocols. Defaults to <see cref="SslProtocols.Tls12" /> and <see cref="SslProtocols.Tls11"/>.
63+
/// Specifies allowable SSL protocols. Defaults to <see cref="SslProtocols.None" /> which allows the operating system to choose the best protocol to use,
64+
/// and to block protocols that are not secure. Unless your app has a specific reason not to, you should use this default.
6565
/// </summary>
6666
public SslProtocols SslProtocols { get; set; }
6767

src/Servers/Kestrel/Core/src/Middleware/HttpsConnectionMiddleware.cs

+2
Original file line numberDiff line numberDiff line change
@@ -252,6 +252,8 @@ public async Task OnConnectionAsync(ConnectionContext context)
252252

253253
KestrelEventSource.Log.TlsHandshakeStop(context, feature);
254254

255+
_logger.LogDebug(3, CoreStrings.HttpsConnectionEstablished, context.ConnectionId, sslStream.SslProtocol);
256+
255257
var originalTransport = context.Transport;
256258

257259
try

src/Servers/Kestrel/test/InMemory.FunctionalTests/HttpsConnectionMiddlewareTests.cs

+2-1
Original file line numberDiff line numberDiff line change
@@ -362,12 +362,13 @@ void ConfigureListenOptions(ListenOptions listenOptions)
362362
}
363363

364364
[Fact]
365-
public async Task DoesNotSupportTls10()
365+
public async Task Tls10CanBeDisabled()
366366
{
367367
void ConfigureListenOptions(ListenOptions listenOptions)
368368
{
369369
listenOptions.UseHttps(options =>
370370
{
371+
options.SslProtocols = SslProtocols.Tls12 | SslProtocols.Tls11;
371372
options.ServerCertificate = _x509Certificate2;
372373
options.ClientCertificateMode = ClientCertificateMode.RequireCertificate;
373374
options.AllowAnyClientCertificate();

src/Servers/Kestrel/test/InMemory.FunctionalTests/HttpsTests.cs

+4-1
Original file line numberDiff line numberDiff line change
@@ -366,7 +366,10 @@ public async Task ClientAttemptingToUseUnsupportedProtocolIsLoggedAsDebug()
366366
new TestServiceContext(LoggerFactory),
367367
listenOptions =>
368368
{
369-
listenOptions.UseHttps(TestResources.GetTestCertificate("no_extensions.pfx"));
369+
listenOptions.UseHttps(TestResources.GetTestCertificate("no_extensions.pfx"), httpsOptions =>
370+
{
371+
httpsOptions.SslProtocols = SslProtocols.Tls12 | SslProtocols.Tls11;
372+
});
370373
}))
371374
{
372375
using (var connection = server.CreateConnection())

0 commit comments

Comments
 (0)