From ba8ce15ab40565d7ac187ce8b6385fb6b3ba0be1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rud=C3=A1=20Cunha?= Date: Thu, 11 Jul 2019 16:28:09 -0300 Subject: [PATCH] Add remote certificate validation callback on server --- Source/MQTTnet/Implementations/MqttTcpServerListener.cs | 2 +- Source/MQTTnet/Server/MqttServerTlsTcpEndpointOptions.cs | 7 +++++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/Source/MQTTnet/Implementations/MqttTcpServerListener.cs b/Source/MQTTnet/Implementations/MqttTcpServerListener.cs index 62eea005..fe0e792b 100644 --- a/Source/MQTTnet/Implementations/MqttTcpServerListener.cs +++ b/Source/MQTTnet/Implementations/MqttTcpServerListener.cs @@ -160,7 +160,7 @@ namespace MQTTnet.Implementations if (_tlsCertificate != null) { - var sslStream = new SslStream(stream, false); + var sslStream = new SslStream(stream, false, _tlsOptions.RemoteCertificateValidationCallback); await sslStream.AuthenticateAsServerAsync( _tlsCertificate, diff --git a/Source/MQTTnet/Server/MqttServerTlsTcpEndpointOptions.cs b/Source/MQTTnet/Server/MqttServerTlsTcpEndpointOptions.cs index 212b0521..3e787ed0 100644 --- a/Source/MQTTnet/Server/MqttServerTlsTcpEndpointOptions.cs +++ b/Source/MQTTnet/Server/MqttServerTlsTcpEndpointOptions.cs @@ -1,4 +1,5 @@ -using System.Security.Authentication; +using System.Net.Security; +using System.Security.Authentication; namespace MQTTnet.Server { @@ -14,7 +15,9 @@ namespace MQTTnet.Server public bool ClientCertificateRequired { get; set; } public bool CheckCertificateRevocation { get; set; } - + + public RemoteCertificateValidationCallback RemoteCertificateValidationCallback { get; set; } + public SslProtocols SslProtocol { get; set; } = SslProtocols.Tls12; } }