diff --git a/Source/MQTTnet/Implementations/MqttTcpChannel.Uwp.cs b/Source/MQTTnet/Implementations/MqttTcpChannel.Uwp.cs index 7d5706d..ce6936c 100644 --- a/Source/MQTTnet/Implementations/MqttTcpChannel.Uwp.cs +++ b/Source/MQTTnet/Implementations/MqttTcpChannel.Uwp.cs @@ -141,7 +141,7 @@ namespace MQTTnet.Implementations if (options.TlsOptions.Certificates.Count > 1) { - throw new NotSupportedException("Only one client certificate is supported for UWP."); + throw new NotSupportedException("Only one client certificate is supported when using 'uap10.0'."); } return new Certificate(options.TlsOptions.Certificates.First().AsBuffer()); diff --git a/Source/MQTTnet/Implementations/MqttTcpServerAdapter.Uwp.cs b/Source/MQTTnet/Implementations/MqttTcpServerAdapter.Uwp.cs index 111850b..2010b5b 100644 --- a/Source/MQTTnet/Implementations/MqttTcpServerAdapter.Uwp.cs +++ b/Source/MQTTnet/Implementations/MqttTcpServerAdapter.Uwp.cs @@ -48,7 +48,7 @@ namespace MQTTnet.Implementations if (options.TlsEndpointOptions.IsEnabled) { - throw new NotSupportedException("TLS servers are not supported for UWP apps."); + throw new NotSupportedException("TLS servers are not supported when using 'uap10.0'."); } } diff --git a/Source/MQTTnet/Implementations/MqttWebSocketChannel.cs b/Source/MQTTnet/Implementations/MqttWebSocketChannel.cs index 70871e4..8d6915f 100644 --- a/Source/MQTTnet/Implementations/MqttWebSocketChannel.cs +++ b/Source/MQTTnet/Implementations/MqttWebSocketChannel.cs @@ -156,10 +156,20 @@ namespace MQTTnet.Implementations } var certificateValidationHandler = _options.TlsOptions?.CertificateValidationHandler; -#if NETSTANDARD2_1 if (certificateValidationHandler != null) { - clientWebSocket.Options.RemoteCertificateValidationCallback = new System.Net.Security.RemoteCertificateValidationCallback((sender, certificate, chain, sslPolicyErrors) => +#if NETSTANDARD1_3 + throw new NotSupportedException("Remote certificate validation callback is not supported when using 'netstandard1.3'."); +#elif NETSTANDARD2_0 + throw new NotSupportedException("Remote certificate validation callback is not supported when using 'netstandard2.0'."); +#elif WINDOWS_UWP + throw new NotSupportedException("Remote certificate validation callback is not supported when using 'uap10.0'."); +#elif NET452 + throw new NotSupportedException("Remote certificate validation callback is not supported when using 'net452'."); +#elif NET461 + throw new NotSupportedException("Remote certificate validation callback is not supported when using 'net461'."); +#else + clientWebSocket.Options.RemoteCertificateValidationCallback = (sender, certificate, chain, sslPolicyErrors) => { // TODO: Find a way to add client options to same callback. Problem is that they have a different type. var context = new MqttClientCertificateValidationCallbackContext @@ -171,14 +181,9 @@ namespace MQTTnet.Implementations }; return certificateValidationHandler(context); - }); - } -#else - if (certificateValidationHandler != null) - { - throw new NotSupportedException("The remote certificate validation callback for Web Sockets is only supported for netstandard 2.1+"); - } + }; #endif + } } void Cleanup() @@ -207,9 +212,9 @@ namespace MQTTnet.Implementations } #if WINDOWS_UWP - throw new NotSupportedException("Proxies are not supported in UWP."); + throw new NotSupportedException("Proxies are not supported when using 'uap10.0'."); #elif NETSTANDARD1_3 - throw new NotSupportedException("Proxies are not supported in netstandard 1.3."); + throw new NotSupportedException("Proxies are not supported when using 'netstandard 1.3'."); #else var proxyUri = new Uri(_options.ProxyOptions.Address);