[rabbitmq-discuss] C# client connect using SSL

michael.thorsoe at schneider-electric.com michael.thorsoe at schneider-electric.com
Wed Nov 6 10:06:53 GMT 2013


I changed from:
        public static Stream TcpUpgrade(Stream tcpStream, SslOption 
sslOption)
        {
            SslHelper helper = new SslHelper(sslOption);
            SslStream sslStream = new SslStream(tcpStream, false,
                                                new 
RemoteCertificateValidationCallback(helper.CertificateValidationCallback),
                                                new 
LocalCertificateSelectionCallback(helper.CertificateSelectionCallback));

            sslStream.AuthenticateAsClient(sslOption.ServerName,
                                           sslOption.Certs,
                                           sslOption.Version,
                                           false);

            return sslStream;
        }
to:
        public static Stream TcpUpgrade(Stream tcpStream, SslOption 
sslOption)
        {
            SslHelper helper = new SslHelper(sslOption);
            SslStream sslStream = new SslStream(tcpStream, false,
                                                new 
RemoteCertificateValidationCallback(helper.CertificateValidationCallback),
                                                new 
LocalCertificateSelectionCallback(helper.CertificateSelectionCallback));

            if (sslOption.Certs == null || sslOption.Certs.Count == 0)
            {
                sslStream.AuthenticateAsClient(sslOption.ServerName);
            }
            else
            {
                sslStream.AuthenticateAsClient(sslOption.ServerName,
                                               sslOption.Certs,
                                               sslOption.Version,
                                               false);
            }

            return sslStream;
        }

I don't know if this is the proper approach but this will allow the call 
to sslStream.AuthenticateAsClient() to NOT assert if no certs is present.

Br,
Michael 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.rabbitmq.com/pipermail/rabbitmq-discuss/attachments/20131106/451a2e59/attachment.htm>


More information about the rabbitmq-discuss mailing list