-
Notifications
You must be signed in to change notification settings - Fork 4.7k
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
API: SSLStream Allow Configuration of CipherSuites #28048
Comments
How does one disable specific ciphers on Windows? Is it via an API? That would be necessary in order for this to work on Windows. And does it require admin permissions or not? Inclusion of ciphers is usually via registry settings. So, I was wondering if this API is actually feasible on Windows. |
Enabling/Disabling is generally done with suites, combinations of ciphers, exchange and signature algorithms, rather than the component parts. The names of the suites are the same in OpenSSL and Windows. I wonder if it's better to stick to this, rather than let people believe that they can be treated as their component parts. There also needs to be the ability to order suites, so the strongest are preferred first, falling back to the less desirable ones. |
API Feedback:
|
@davish, yes, Windows has added an API in RS5 for disabling ciphers (not ciphersuites), also older versions have something resembling that API. You have to use SCH_CREDENTIALS structure which takes list of TLS_PARAMETERS which restrict ciphers.
@blowdart, I agree that would be ideal as it is the most flexible option - it is what the spec defines but API on Windows does not allow to do this - only disabling ciphers (almost exactly as this API proposal with couple of more options). We can later add platform specific API for disabling specific ciphersuites on Linux/OSX and throw PNSE on Windows. After giving it some thought before I think disabling ciphers is also good or better as you can express: "I do not trust RC4", "I do not trust ECDsa" rather than "I do not trust ECDsa but only if it is used along with ...."
Window currently does not support it. I think OpenSSL & OSX do. If we pick that only disabling is possible as in this proposal we do let OS choose for us.
I actually made it settable so I do not really care if someone does or does not cast it. I'd rather mention in the docs to not rely on a specific type returned by this API but if this is the practice we do everywhere else we can change it with i.e. HashSet or something else (or implement ISet as internal type and return that to avoid casting).
I'll try to match them where possible, for other values as I've proposed we can choose something which will unlikely be used such as
This was intentional, OpenSSL currently doesn't have any ECDH which are not ephermal (at least on the version I've checked) - I don't mind using the full name but initially I thought about |
If the Windows API doesn't allow this then the Windows API is wrong. It's how it's done in the registry globally, it's how it's done in ngenix and apache, and Windows needs a slap. Can you map the suite strings to the underlying primitives instead for a consistent API in .NET? |
@blowdart, I think it should be doable (specifying ciphersuites) but I still think some kind of filtering is preferable in most of the cases, I can't think of a case where you would want to disable ECDsa in one context but not in another - you either trust it or not. I can see that specifying prefered order would have to be with full ciphersuites but for disabling I'm not convinced. |
I think it's more a case of an API being as expected, and no-one configures HTTPS on an algorithm alone, they're always combinations. |
@blowdart I think the configuration with ciphers is less error prone and much easier but I can see how API which is consistent between different implementations of SslStream is useful but I do not think we should necessarily follow that convention. |
Some thoughts.
Mostly, but they differ in exact formatting if it is decided that strings are accepted as input. e.g. Windows: "TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256" No "TLS" prefix and "WITH" in OpenSSL, and different separators. If a string of suites are accepted, It'd have to be normalized for the right platform somehow. |
|
Just supporting disabling, without the ability to order the remaining the ciphers, makes this unusable for any use case I can think of. I believe ordering must be a requirement. |
Hey, I have updated suggestion based on feedback - please let me know what you think: Changes:
Not added/changed yet:
|
@mattzink why do you think so? Do you not believe in OS ability to do it correctly? |
Another changelist:
|
Looks good, but I hope there are plans to pare back some of the old things that should not be in there like Kerberos, NULL, anon, etc. If someone REALLY wanted to use bad suites and knew what they were doing they could cast a value to the enum like Along the same lines, it seems somewhat scary that the default value for the enum is also the least secure. e.g. if someone wrote this: public void Foo(CipherSuite suite = default) => throw null; I think most TLS implementations disallow this anyway, but it also makes a better case for not putting TLS_NULL_WITH_NULL_NULL in the enum at all and implementations can throw if the enum value's value 0 since there is zero reason to use it today. |
@vcsjones 0 is a legal value for any enum, so I think it's much easier to say that we'll regularly regenerate the list from the IANA registry, but making a policy around what to exclude gets weird (and is usually a thing we can only do once... making the exclusions look weird in 5 years). |
Yes that is why my rational was to throw if the enum is 0, too:
Sorry if I wasn't clear, but what I am advocating for is the enum having no usable default. Don't define anything for zero and APIs should throw if they are given a 0 value, or |
@vcsjones EncryptionPolicy controls the behavior for NULL ciphers so it won't get added by accident anyway. I'll make sure to respect that when you set AllowedCipherSuites |
another change:
this is to disambiguate between MAC vs hash used for key derivation |
To keep the thread updated - I have prototyped two solutions here:
My previous assumptions about disallow list of ciphers being better was broken in testing - really error prone from user and library perspective and comes with the future maintenance cost of having to know everything about every cipher suite. My current stance is that allow list of cipher suites is much less error prone and more intuitive and I believe that's what the design should look like. |
Going through the builder feels odd; especially because it doesn't itself represent a collection. It seems more natural to do something like: public sealed class CipherSuitesPolicy
{
public CipherSuitesPolicy(IEnumerable<TlsCipherSuite> allowedCipherSuites);
public IEnumerable<TlsCipherSuite> AllowedCipherSuites { get; }
} It was proposed to apply hide the |
Note: OpenSsl 1.1.1 or OSX is required. Windows is not supported at the moment. |
Forking off the main thread: https://github.com/dotnet/corefx/issues/24588 to stick to APIs
Depends on: https://github.com/dotnet/corefx/issues/34867 (approved)
The text was updated successfully, but these errors were encountered: