Skip to content
This repository was archived by the owner on Jan 23, 2023. It is now read-only.

Negotiated ciphersuite#35029

Merged
krwq merged 13 commits intodotnet:masterfrom
krwq:negotiated_ciphersuite
Apr 5, 2019
Merged

Negotiated ciphersuite#35029
krwq merged 13 commits intodotnet:masterfrom
krwq:negotiated_ciphersuite

Conversation

@krwq
Copy link
Member

@krwq krwq commented Feb 1, 2019

Fixes: https://github.com/dotnet/corefx/issues/34867

Motivation:
Needed for https://github.com/dotnet/corefx/issues/33809

This fixes two issues:

support for:

@krwq krwq added the * NO MERGE * The PR is not ready for merge yet (see discussion for detailed reasons) label Feb 1, 2019
@karelz karelz added the blocked Issue/PR is blocked on something - see comments label Mar 4, 2019
@karelz
Copy link
Member

karelz commented Mar 4, 2019

Still blocked on API review + validation that Windows is implementable

@krwq krwq force-pushed the negotiated_ciphersuite branch from 6a3b296 to 4958145 Compare March 6, 2019 21:04
@krwq
Copy link
Member Author

krwq commented Mar 6, 2019

@karelz to clarify - Windows is implementable (negotiated cipher suite - not policy - it was already included in the previous version) - what's missing right now is just API review (previously this was also missing fixes for OSX and merge conflict which creeped in much more stuff than I initially wanted here)

@karelz
Copy link
Member

karelz commented Mar 18, 2019

@krwq do we have final API shape yet? The associated issue is NOT marked as ready for API review ... (sorry there may have been emails about it I forgot about)

@krwq
Copy link
Member Author

krwq commented Mar 18, 2019

@karelz this is is marked as ready for review for a while (since Jan 25):
https://github.com/dotnet/corefx/issues/34867

cipher suite policy issue (https://github.com/dotnet/corefx/issues/33809) is not yet (this issue adds internals needed for cipher suite policy feature and has only APIs which are very unlikely to get changed during API review) but that APIs depend on this so cannot finalize them before this one is finalized (although I got a changeset somewhere with most likely shape on my fork)

@karelz
Copy link
Member

karelz commented Mar 18, 2019

Ah, mix up on my side, thanks for clarification!

@davidsh
Copy link
Contributor

davidsh commented Mar 19, 2019

Given the recent API review and approval https://github.com/dotnet/corefx/issues/34867#issuecomment-474516862, will this property be changed to nullable, or just throw when not available yet?

@krwq
Copy link
Member Author

krwq commented Mar 21, 2019

@davidsh all similar APIs currently throw so I have followed that pattern and I think it makes sense to throw from consistency point of view (also this value doesn't make any sense before negotiation is successful so it is likely a user bug). I do not feel strongly either way though so please let me know if you prefer nullable.

@khellang
Copy link
Member

I think the API review landed on throwing and nullable? Throw for invalid state, return null if the platform is unable to provide the value.

@krwq
Copy link
Member Author

krwq commented Mar 21, 2019

@khellang I think currently all platforms are able to provide a value - at least AFAIK - I'm not sure if the API review feedback was throw OR nullable or throw AND nullable - I don't mind either way - just feels like nullable will never be null. I will check with @terrajobst whenever I see him

@khellang
Copy link
Member

I think it was @vcsjones that suggested it might be a good idea to make it nullable in case a future platform can't provide the value, instead of returning a bogus value or throwing.

@krwq
Copy link
Member Author

krwq commented Mar 21, 2019

makes sense - I'll double check with @terrajobst if this is what he meant as well and update accordingly (first need to fix merge conflicts and failures anyway, that will be just cosmetic change)

@vcsjones
Copy link
Member

Yes I think the conversation leaned toward nullable and throw.

  • Throw like other properties on this class do if the stream is not in a state to provide this information.
  • Return null if there is any reason we can't actually return the information later.

Really my concern was, we don't own the values of the enum, IANA does, so we can never add an "Unknown" value to the enum. Making it nullable was trying to be a bit forward thinking.

@krwq krwq removed the blocked Issue/PR is blocked on something - see comments label Mar 21, 2019
@krwq krwq force-pushed the negotiated_ciphersuite branch from 4958145 to 8063575 Compare March 21, 2019 22:53
@krwq krwq changed the title [DO NOT MERGE] Negotiated ciphersuite Negotiated ciphersuite Mar 22, 2019
@krwq krwq removed the * NO MERGE * The PR is not ready for merge yet (see discussion for detailed reasons) label Mar 22, 2019
{
Protocol = (int)MapProtocolVersion(Interop.Ssl.SslGetVersion(sslContext));

MapCipherSuite(SslGetCurrentCipherSuite(sslContext));
Copy link
Member

Choose a reason for hiding this comment

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

We should be consistent: it's strange to have one of these Map... methods update state and the other not.

Copy link
Member Author

Choose a reason for hiding this comment

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

this was existing code I moved to different place so that we can use it on both Linux and OSX - also this maps 1 value into 6 so don't see any clean way to write that except for copy & paste

@krwq krwq force-pushed the negotiated_ciphersuite branch from 34f012f to 533411d Compare April 1, 2019 19:11
@krwq
Copy link
Member Author

krwq commented Apr 1, 2019

this was pure rebase to pick up new yaml files and fix the build


public static string ToFrameworkName(HashAlgorithmType val)
{
return val == HashAlgorithmType.Aead ? "None" : val.ToString();
Copy link
Member

Choose a reason for hiding this comment

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

Consider expanding this, and doing the open-drain-throw default.

Copy link
Member Author

Choose a reason for hiding this comment

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

currently we have 1:1 mapping except Aead so will leave it as is for simplicity

Copy link
Member

Choose a reason for hiding this comment

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

I'm not suggesting changing it to be anything complicated, just explicit-case on the 1:1 mapping (returning val.ToString() still) and letting Aead be None, and anything future throw so whoever is making the change figures out what to do about it.

The reason I brought it up is I think everything else currently throws on new kinds of data, so someone might hit a deceptive "I'm done" state instead of being really done.

Copy link
Member Author

@krwq krwq Apr 5, 2019

Choose a reason for hiding this comment

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

will add it it in my coming ciphersuite policy PR

@krwq krwq merged commit f9fbe70 into dotnet:master Apr 5, 2019
picenka21 pushed a commit to picenka21/runtime that referenced this pull request Feb 18, 2022
* NegotiatedCiphersuite implementation

* fix after merge conflict

* fix netfx

* add more expected Tls 1.0 ciphersuites (rfc5289)

* change TlsCipherSuite API to nullable

* apply self-feedback

* apply feedback

* Revert "change TlsCipherSuite API to nullable"

This reverts commit dotnet/corefx@c8bffcc.

* simplification around nullables

* msbuild /t:GenerateReferenceSource instead of copy & paste

* revert badly generated APIs

* fix codegen after moving tt files

* apply feedback


Commit migrated from dotnet/corefx@f9fbe70
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add SslStream.NegotiatedCipherSuite

7 participants