From 522a38552310e911e605e7edf117872c07363cd9 Mon Sep 17 00:00:00 2001 From: Christian Kratky Date: Wed, 8 Nov 2017 20:26:33 +0100 Subject: [PATCH] Add methods for client options builder --- .../Client/MqttClientOptionsBuilder.cs | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/MQTTnet.Core/Client/MqttClientOptionsBuilder.cs b/MQTTnet.Core/Client/MqttClientOptionsBuilder.cs index 1eb2a34..b352567 100644 --- a/MQTTnet.Core/Client/MqttClientOptionsBuilder.cs +++ b/MQTTnet.Core/Client/MqttClientOptionsBuilder.cs @@ -1,4 +1,5 @@ using System; +using System.Linq; using MQTTnet.Core.Serializer; namespace MQTTnet.Core.Client @@ -79,6 +80,24 @@ namespace MQTTnet.Core.Client return this; } + public MqttClientOptionsBuilder WithTls( + bool allowUntrustedCertificates = false, + bool ignoreCertificateChainErrors = false, + bool ignoreCertificateRevocationErrors = false, + params byte[][] certificates) + { + _tlsOptions = new MqttClientTlsOptions + { + UseTls = true, + AllowUntrustedCertificates = allowUntrustedCertificates, + IgnoreCertificateChainErrors = ignoreCertificateChainErrors, + IgnoreCertificateRevocationErrors = ignoreCertificateRevocationErrors, + Certificates = certificates.ToList() + }; + + return this; + } + public MqttClientOptionsBuilder WithTls() { _tlsOptions = new MqttClientTlsOptions