Skip to content

Use default SslProtocols in Kestrel #22437

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jun 4, 2020
Merged

Conversation

halter73
Copy link
Member

@halter73 halter73 commented Jun 1, 2020

Addresses #14997

I hope to get this into preview6. I will make a breaking change announcement.

@halter73 halter73 added breaking-change This issue / pr will introduce a breaking change, when resolved / merged. area-servers feature-kestrel labels Jun 1, 2020
@halter73 halter73 added this to the 5.0.0-preview6 milestone Jun 1, 2020
@halter73 halter73 requested review from blowdart and Tratcher June 1, 2020 22:47
@halter73 halter73 requested a review from jkotalik as a code owner June 1, 2020 22:47
@Tratcher
Copy link
Member

Tratcher commented Jun 1, 2020

Did you want to put it in the preview6 branch first? Or do you plan to cherry pick?

@Tratcher
Copy link
Member

Tratcher commented Jun 1, 2020

I'm a little concerned that you didn't have to update any tests...

@halter73
Copy link
Member Author

halter73 commented Jun 1, 2020

I'm a little concerned that you didn't have to update any tests...

I did. I just pushed before tests finished 😆

I'll retarget to release/5.0-preview6.

@halter73 halter73 changed the base branch from master to release/5.0-preview6 June 1, 2020 23:01
@halter73
Copy link
Member Author

halter73 commented Jun 1, 2020

@blowdart Do you want us to log anything if a client connects using TLS 1.0 or SSL? If so, should we log a warning the first time this happens? On every connection where this happens?

Copy link
Contributor

@blowdart blowdart left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With logging, sure. I think log protocol for every connection as informational. This is useful because it'll allow a developer to gather stats so they can, for example, know when it's safe to turn an older protocol off.

If the OS is configured correctly, you wouldn't even get to the log though would you? Http.sys for example would refuse the connection.

@halter73
Copy link
Member Author

halter73 commented Jun 2, 2020

If the OS is configured correctly, you wouldn't even get to the log though would you? Http.sys for example would refuse the connection.

Kestrel refuses the connection but still logs the authentication failure at the debug level. Kestrel doesn't know why the handshake failed. It simply catches AuthenticationExceptions thrown by AuthenticateAsServerAsync and logs it.

With logging, sure. I think log protocol for every connection as informational.

I can log the protocol for every TLS/SSL connection. I think it would be at the debug level like we do for AuthenticationExceptions though.

@blowdart If we see that TLS 1.0 or SSL is being used, should we log something different or increase the log severity?

@blowdart
Copy link
Contributor

blowdart commented Jun 2, 2020

Can we make the log severity configurable? It could get noisy, and the ability to let folks choose would be useful.

@halter73
Copy link
Member Author

halter73 commented Jun 2, 2020

Can we make the log severity configurable? It could get noisy, and the ability to let folks choose would be useful.

I don't think we ever make the severity we log at configurable. We generally try to pick a reasonable level for each log and let customers configure a min log level with namespace granularity.

Debug is pretty noisy, but at least it's not trace. I'm OK with trying info if you think that's better.

listenOptions.UseHttps(TestResources.GetTestCertificate("no_extensions.pfx"));
listenOptions.UseHttps(TestResources.GetTestCertificate("no_extensions.pfx"), httpsOptions =>
{
httpsOptions.SslProtocols = SslProtocols.Tls12 | SslProtocols.Tls11;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What happens without this?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm deleting my last comment and resubmitting so those reading this via notifications or email will hopefully be less confused. I wrote "is not" in the last comment when I meant "is".

TLS 1.0 is not allowed by default on my Windows 10 Insider Preview machine. This was brought up as a problem in #14997, is why we didn't use the defaults in the first place, and is why I was asking about whether we should log at a higher level if TLS 1.0 or SSL is used.

@halter73
Copy link
Member Author

halter73 commented Jun 4, 2020

@blowdart I've updated the PR to log the "SslProtocol" at the debug level after a successful handshake. This is what the logs look like at the start of a TLS 1.2 connection with debug logs enabled:

dbug: Microsoft.AspNetCore.Server.Kestrel[39]
      Connection id "0HM085QVC1C8G" accepted.
dbug: Microsoft.AspNetCore.Server.Kestrel[1]
      Connection id "0HM085QVC1C8G" started.
dbug: Microsoft.AspNetCore.Server.Kestrel.Https.Internal.HttpsConnectionMiddleware[3]
      Connection "0HM085QVC1C8G" established using the following protocol: Tls12
info: Microsoft.AspNetCore.Hosting.Diagnostics[1]
      Request starting HTTP/2 GET https://localhost:5001/ - -

Does this seem reasonable to you?

There's a lot of additional details we could log about the connection like the CipherAlgorithm, but we can address that separately. It's already possible for developers to log additional details themselves using the ITlsHandshakeFeature.

@blowdart
Copy link
Contributor

blowdart commented Jun 4, 2020

Works for me :) A sample for logging the rest would be good.

@Pilchie
Copy link
Member

Pilchie commented Jun 4, 2020

I approve, and agree with trying to get it in early.

@halter73
Copy link
Member Author

halter73 commented Jun 4, 2020

@Pilchie Can you merge this?

@Pilchie Pilchie merged commit a50f94e into release/5.0-preview6 Jun 4, 2020
@Pilchie Pilchie deleted the halter73/14997 branch June 4, 2020 23:44
@halter73 halter73 restored the halter73/14997 branch June 23, 2020 00:21
@halter73 halter73 deleted the halter73/14997 branch June 23, 2020 00:21
@amcasey amcasey added area-networking Includes servers, yarp, json patch, bedrock, websockets, http client factory, and http abstractions and removed area-runtime labels Jun 2, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-networking Includes servers, yarp, json patch, bedrock, websockets, http client factory, and http abstractions breaking-change This issue / pr will introduce a breaking change, when resolved / merged. feature-kestrel
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants