Closed simonthum closed 2 years ago
This was last changed in Oct. 2021: https://github.com/dotnet/MQTTnet/pull/1271
I favor leaving SSLprotocols to the OS, but older .net will fail, so you have to specify. Note this is an enum Flag, you can specify SslProtocols.Tls | SslProtocols.Tls11 | SslProtocols.Tls12
, no need to single out a specific revision.
To be clear, this isn't so bad. It's quite straightforward to get from error message to the workaround, i.e. explicitly naming TLS versions. But I still think a default value should not cause needless failure.
That should be a small change. I will consider adding this soon.
Thank you!
The preprocessor directives can be found here: https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/preprocessor-directives (Just for reference that it's here as well).
I have added #if NET452 || NET46 || NET461 || NET462
. Is there any other versions (NetStandard, UWP, ...) concerned as well with this problem?
@SeppPenner None that I know of. (451 and 45 are not on your support list, I suppose)
Ms devotes a document to the topic. I linked the relevant section, it's a long read.
If I'm reading this right .net 4.7 is affected, but not 4.7.1 and above. Others are not mentioned.
@SeppPenner None that I know of. (451 and 45 are not on your support list, I suppose)
Yes, only .NET Framework 4.5.2+ is supported :)
Ms devotes a document to the topic. I linked the relevant section, it's a long read.
If I'm reading this right .net 4.7 is affected, but not 4.7.1 and above. Others are not mentioned.
I agree, seems like 4.7 is affected as well.
Maybe is is more straightforward to use an overload without SslProtocol
value when it's value is None
.
Describe the bug
Just enabling TLS in MQTTnet will yield a Sslprotocols value of
SslProtocols.None
. This value is invalid under .net 4.6 and earlier, a fact enforced in .net 4.8 too. It throws ArgumentException, see below.Nota bene: In 4.7 and beyond,
SslProtocols.None
leaves it to the OS to decide, which is not a bad idea, so in any case the fix should change the default only for affected targets..net side enforcement:
https://referencesource.microsoft.com/#System/net/System/Net/SecureProtocols/_SslState.cs,165
Default 1:
https://github.com/dotnet/MQTTnet/blob/d5691346a9d2433e3530fda571f1c8defbe70c6f/Source/MQTTnet/Client/Options/MqttClientOptionsBuilderTlsParameters.cs#L22
Default 2:
https://github.com/dotnet/MQTTnet/blob/d5691346a9d2433e3530fda571f1c8defbe70c6f/Source/MQTTnet/Client/Options/MqttClientTlsOptions.cs#L29
Which project is your bug related to?
To Reproduce
Open a connection using TLS in a .net 4.6 vanilla (no special SSL settings, neither in .net nor MQTTnet) compiled app. You do not need an actual broker. We got this tace (german):
Expected behavior
Some default suite of SSL versions should be picked to at least attempt a connection.
Code example