From 07ad9fc557588c894839daaf4dc66d9d17ab83a3 Mon Sep 17 00:00:00 2001 From: Ben Origas Date: Wed, 15 Apr 2020 09:55:23 -0500 Subject: [PATCH] Add exception if both Certificate and X509Certificate are set --- Source/MQTTnet/Implementations/MqttTcpServerAdapter.cs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Source/MQTTnet/Implementations/MqttTcpServerAdapter.cs b/Source/MQTTnet/Implementations/MqttTcpServerAdapter.cs index 8bc03904..25879bfd 100644 --- a/Source/MQTTnet/Implementations/MqttTcpServerAdapter.cs +++ b/Source/MQTTnet/Implementations/MqttTcpServerAdapter.cs @@ -48,6 +48,10 @@ namespace MQTTnet.Implementations { throw new ArgumentException("TLS certificate is not set."); } + else if (options.TlsEndpointOptions.Certificate != null && options.TlsEndpointOptions.X509Certificate != null) + { + throw new ArgumentException($"{nameof(MqttServerTlsTcpEndpointOptions.Certificate)} and {nameof(MqttServerTlsTcpEndpointOptions.X509Certificate)} cannot both be set"); + } X509Certificate2 tlsCertificate; if (options.TlsEndpointOptions.X509Certificate != null)