diff --git a/Build/MQTTnet.nuspec b/Build/MQTTnet.nuspec index f47029a..1c496d0 100644 --- a/Build/MQTTnet.nuspec +++ b/Build/MQTTnet.nuspec @@ -16,6 +16,7 @@ * [Server] Exposed CONNECT packet properties in Application Message and Subscription interceptor. * [Server] Fixed: Sending Large packets with AspnetCore based connection throws System.ArgumentException. * [Server] Fixed wrong usage of socket option _NoDelay_. +* [Server] Added remote certificate validation callback (thanks to @rudacs). * [MQTTnet.Server] Added REST API for publishing basic messages. Copyright Christian Kratky 2016-2019 diff --git a/Source/MQTTnet/Server/MqttServerOptionsBuilder.cs b/Source/MQTTnet/Server/MqttServerOptionsBuilder.cs index 357cb82..1fcd981 100644 --- a/Source/MQTTnet/Server/MqttServerOptionsBuilder.cs +++ b/Source/MQTTnet/Server/MqttServerOptionsBuilder.cs @@ -1,5 +1,6 @@ using System; using System.Net; +using System.Net.Security; using System.Security.Authentication; namespace MQTTnet.Server @@ -98,7 +99,15 @@ namespace MQTTnet.Server _options.TlsEndpointOptions.IsEnabled = false; return this; } - + +#if !WINDOWS_UWP + public MqttServerOptionsBuilder WithRemoteCertificateValidationCallback(RemoteCertificateValidationCallback value) + { + _options.TlsEndpointOptions.RemoteCertificateValidationCallback = value; + return this; + } +#endif + public MqttServerOptionsBuilder WithStorage(IMqttServerStorage value) { _options.Storage = value; diff --git a/Source/MQTTnet/Server/MqttServerTlsTcpEndpointOptions.cs b/Source/MQTTnet/Server/MqttServerTlsTcpEndpointOptions.cs index 3e787ed..282bef9 100644 --- a/Source/MQTTnet/Server/MqttServerTlsTcpEndpointOptions.cs +++ b/Source/MQTTnet/Server/MqttServerTlsTcpEndpointOptions.cs @@ -16,8 +16,9 @@ namespace MQTTnet.Server public bool CheckCertificateRevocation { get; set; } +#if !WINDOWS_UWP public RemoteCertificateValidationCallback RemoteCertificateValidationCallback { get; set; } - +#endif public SslProtocols SslProtocol { get; set; } = SslProtocols.Tls12; } }