private static MCertificate GetClientCert(IBrokerInfo broker) { // if a client certificate is configured, // use that to enable mutual authentication MCertificate cert = null; if (broker.SslOptions != null && broker.SslOptions.ClientCertificate != null) { cert = MCertificate.CreateFromX509Certificate( broker.SslOptions.ClientCertificate ); _logger.DebugFormat("Using Client Certificate for SSL '{0}'", cert.ToString(true)); } return(cert); }
public Stream Connect(IBrokerInfo broker) { MCertificate cert = GetClientCert(broker); SecurityOptions options = new SecurityOptions( SecureProtocol.Tls1, cert, ConnectionEnd.Client ); if (broker.SslOptions != null && broker.SslOptions.IgnoreValidationErrors) { _logger.Warn("Ignoring any certificate validation errors during SSL handshake..."); options.VerificationType = CredentialVerification.None; } _tcpClient = new MyTcpClient(broker.Host, broker.Port, options); return(_tcpClient.GetStream()); }