@@ -85,7 +85,12 @@ namespace MQTTnet.Extensions.WebSocket4Net | |||||
{ | { | ||||
foreach (var certificate in _webSocketOptions.TlsOptions.Certificates) | foreach (var certificate in _webSocketOptions.TlsOptions.Certificates) | ||||
{ | { | ||||
#if WINDOWS_UWP | |||||
certificates.Add(new X509Certificate(certificate)); | |||||
#else | |||||
certificates.Add(certificate); | certificates.Add(certificate); | ||||
#endif | |||||
} | } | ||||
} | } | ||||
@@ -256,7 +256,11 @@ namespace MQTTnet.Client.Options | |||||
UseTls = true, | UseTls = true, | ||||
SslProtocol = _tlsParameters.SslProtocol, | SslProtocol = _tlsParameters.SslProtocol, | ||||
AllowUntrustedCertificates = _tlsParameters.AllowUntrustedCertificates, | AllowUntrustedCertificates = _tlsParameters.AllowUntrustedCertificates, | ||||
#if WINDOWS_UWP | |||||
Certificates = _tlsParameters.Certificates?.Select(c => c.ToArray()).ToList(), | |||||
#else | |||||
Certificates = _tlsParameters.Certificates?.ToList(), | Certificates = _tlsParameters.Certificates?.ToList(), | ||||
#endif | |||||
CertificateValidationCallback = _tlsParameters.CertificateValidationCallback, | CertificateValidationCallback = _tlsParameters.CertificateValidationCallback, | ||||
IgnoreCertificateChainErrors = _tlsParameters.IgnoreCertificateChainErrors, | IgnoreCertificateChainErrors = _tlsParameters.IgnoreCertificateChainErrors, | ||||
IgnoreCertificateRevocationErrors = _tlsParameters.IgnoreCertificateRevocationErrors | IgnoreCertificateRevocationErrors = _tlsParameters.IgnoreCertificateRevocationErrors | ||||
@@ -18,7 +18,12 @@ namespace MQTTnet.Client.Options | |||||
public SslProtocols SslProtocol { get; set; } = SslProtocols.Tls12; | public SslProtocols SslProtocol { get; set; } = SslProtocols.Tls12; | ||||
#if WINDOWS_UWP | |||||
public IEnumerable<IEnumerable<byte>> Certificates { get; set; } | |||||
#else | |||||
public IEnumerable<X509Certificate> Certificates { get; set; } | public IEnumerable<X509Certificate> Certificates { get; set; } | ||||
#endif | |||||
public bool AllowUntrustedCertificates { get; set; } | public bool AllowUntrustedCertificates { get; set; } | ||||
@@ -15,8 +15,11 @@ namespace MQTTnet.Client.Options | |||||
public bool IgnoreCertificateChainErrors { get; set; } | public bool IgnoreCertificateChainErrors { get; set; } | ||||
public bool AllowUntrustedCertificates { get; set; } | public bool AllowUntrustedCertificates { get; set; } | ||||
#if WINDOWS_UWP | |||||
public List<byte[]> Certificates { get; set; } | |||||
#else | |||||
public List<X509Certificate> Certificates { get; set; } | public List<X509Certificate> Certificates { get; set; } | ||||
#endif | |||||
public SslProtocols SslProtocol { get; set; } = SslProtocols.Tls12; | public SslProtocols SslProtocol { get; set; } = SslProtocols.Tls12; | ||||
@@ -132,7 +132,7 @@ namespace MQTTnet.Implementations | |||||
throw new NotSupportedException("Only one client certificate is supported for UWP."); | throw new NotSupportedException("Only one client certificate is supported for UWP."); | ||||
} | } | ||||
return new Certificate(options.TlsOptions.Certificates.First().GetRawCertData()); | |||||
return new Certificate(options.TlsOptions.Certificates.First().AsBuffer()); | |||||
} | } | ||||
private IEnumerable<ChainValidationResult> ResolveIgnorableServerCertificateErrors() | private IEnumerable<ChainValidationResult> ResolveIgnorableServerCertificateErrors() | ||||
@@ -84,7 +84,12 @@ namespace MQTTnet.Implementations | |||||
clientWebSocket.Options.ClientCertificates = new X509CertificateCollection(); | clientWebSocket.Options.ClientCertificates = new X509CertificateCollection(); | ||||
foreach (var certificate in _options.TlsOptions.Certificates) | foreach (var certificate in _options.TlsOptions.Certificates) | ||||
{ | { | ||||
#if WINDOWS_UWP | |||||
clientWebSocket.Options.ClientCertificates.Add(new X509Certificate(certificate)); | |||||
#else | |||||
clientWebSocket.Options.ClientCertificates.Add(certificate); | clientWebSocket.Options.ClientCertificates.Add(certificate); | ||||
#endif | |||||
} | } | ||||
} | } | ||||