diff --git a/Source/MQTTnet/Implementations/MqttTcpChannel.cs b/Source/MQTTnet/Implementations/MqttTcpChannel.cs index 5dbfd8dd..3c173947 100644 --- a/Source/MQTTnet/Implementations/MqttTcpChannel.cs +++ b/Source/MQTTnet/Implementations/MqttTcpChannel.cs @@ -3,6 +3,9 @@ // See the LICENSE file in the project root for more information. #if !WINDOWS_UWP +using MQTTnet.Channel; +using MQTTnet.Client; +using MQTTnet.Exceptions; using System; using System.IO; using System.Net.Security; @@ -11,9 +14,6 @@ using System.Runtime.ExceptionServices; using System.Security.Cryptography.X509Certificates; using System.Threading; using System.Threading.Tasks; -using MQTTnet.Channel; -using MQTTnet.Client; -using MQTTnet.Exceptions; namespace MQTTnet.Implementations { @@ -274,6 +274,9 @@ namespace MQTTnet.Implementations return certificateValidationHandler(eventArgs); } + if (_tcpOptions?.TlsOptions?.IgnoreCertificateChainErrors ?? false) + sslPolicyErrors &= ~SslPolicyErrors.RemoteCertificateChainErrors; + return sslPolicyErrors == SslPolicyErrors.None; }