diff --git a/Build/MQTTnet.nuspec b/Build/MQTTnet.nuspec index dc42668..a5242c4 100644 --- a/Build/MQTTnet.nuspec +++ b/Build/MQTTnet.nuspec @@ -16,6 +16,8 @@ * [Core] Decreased object allocations (#1324, thanks to @gfoidl). * [Core] Decreased object allocations when logging is not active (thanks to @gfoidl, @Tymoniden). * [Client] Fixed issue in _MqttApplicationMessageBuilder.WithPayload_ (#1322, thanks to @gfoidl). +* [Client] Adjusted default SslProtocol values to Tls12 and Tls13 (#1347). +* [Extensions.WebSocket4Net] Adjusted default SslProtocol values to Tls12 and Tls13 (#1347). Git commit: $gitCommit diff --git a/Source/MQTTnet.Extensions.WebSocket4Net/WebSocket4NetMqttChannel.cs b/Source/MQTTnet.Extensions.WebSocket4Net/WebSocket4NetMqttChannel.cs index a7ad56b..930ab7e 100644 --- a/Source/MQTTnet.Extensions.WebSocket4Net/WebSocket4NetMqttChannel.cs +++ b/Source/MQTTnet.Extensions.WebSocket4Net/WebSocket4NetMqttChannel.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Collections.Concurrent; using System.Collections.Generic; using System.Linq; @@ -52,7 +52,12 @@ namespace MQTTnet.Extensions.WebSocket4Net } } - var sslProtocols = _webSocketOptions?.TlsOptions?.SslProtocol ?? SslProtocols.None; +#if NET48 || NETCOREAPP3_1 || NET5 || NET6 + var sslProtocols = _webSocketOptions?.TlsOptions.SslProtocol ?? SslProtocols.Tls12 | SslProtocols.Tls13; +#else + var sslProtocols = _webSocketOptions?.TlsOptions.SslProtocol ?? SslProtocols.Tls12 | (SslProtocols)0x00003000 /*Tls13*/; +#endif + var subProtocol = _webSocketOptions.SubProtocols.FirstOrDefault() ?? string.Empty; var cookies = new List>(); diff --git a/Source/MQTTnet/Client/Options/MqttClientOptionsBuilderTlsParameters.cs b/Source/MQTTnet/Client/Options/MqttClientOptionsBuilderTlsParameters.cs index 27ad435..a523cd0 100644 --- a/Source/MQTTnet/Client/Options/MqttClientOptionsBuilderTlsParameters.cs +++ b/Source/MQTTnet/Client/Options/MqttClientOptionsBuilderTlsParameters.cs @@ -19,7 +19,11 @@ namespace MQTTnet.Client.Options public Func CertificateValidationHandler { get; set; } - public SslProtocols SslProtocol { get; set; } = SslProtocols.None; +#if NET48 || NETCOREAPP3_1 || NET5 || NET6 + public SslProtocols SslProtocol { get; set; } = SslProtocols.Tls12 | SslProtocols.Tls13; +#else + public SslProtocols SslProtocol { get; set; } = SslProtocols.Tls12 | (SslProtocols)0x00003000 /*Tls13*/; +#endif #if WINDOWS_UWP public IEnumerable> Certificates { get; set; } diff --git a/Source/MQTTnet/Client/Options/MqttClientTlsOptions.cs b/Source/MQTTnet/Client/Options/MqttClientTlsOptions.cs index e2d57ee..9ad1897 100644 --- a/Source/MQTTnet/Client/Options/MqttClientTlsOptions.cs +++ b/Source/MQTTnet/Client/Options/MqttClientTlsOptions.cs @@ -26,7 +26,11 @@ namespace MQTTnet.Client.Options public List ApplicationProtocols { get; set; } #endif - public SslProtocols SslProtocol { get; set; } = SslProtocols.None; +#if NET48 || NETCOREAPP3_1 || NET5 || NET6 + public SslProtocols SslProtocol { get; set; } = SslProtocols.Tls12 | SslProtocols.Tls13; +#else + public SslProtocols SslProtocol { get; set; } = SslProtocols.Tls12 | (SslProtocols)0x00003000 /*Tls13*/; +#endif [Obsolete("This property will be removed soon. Use CertificateValidationHandler instead.")] public Func CertificateValidationCallback { get; set; }