1
Vote

SecurityPolicies.Explicit vs Implicit - change handling code, they work in an opposite way

description

The policies are handled opposite as it's expected.

This is how it should be:
http://www.rebex.net/kb/tls-ssl-explicit-implicit/default.aspx

As you see from the code below, actually code for SecurityPolicies.Explicit is the code that should be for implicit connection... and vice versa.

I have a SMTP connection with port 465, it uses an implicit SSL connection, but had to set SecurityPolicies.Explicit with your code to work. I would not have figured it out without checking code with ILSpy :D

public virtual void Connect(string host, int port)
    {
        this._tcpClient.Connect(host, port);
        NetworkStream stream = this._tcpClient.GetStream();
        this._reader = new System.IO.StreamReader(stream, System.Text.Encoding.UTF8, false);
        this._writer = new System.IO.StreamWriter(stream)
        {
            AutoFlush = true
        };
        if (this.Security == SecurityPolicies.Explicit)
        {
            this.NegotiateEncryptionProtocols(host);
            this.ReadWelcomeMessage();
            this.FetchCapabilities();
        }
        else
        {
            this.ReadWelcomeMessage();
            this.FetchCapabilities();
            if (this.Security == SecurityPolicies.Implicit)
            {
                bool flag = this.IsTlsSupported();
                if (flag)
                {
                    bool flag2 = this.IssueStartTlsCommand(host);
                    if (flag2)
                    {
                        this.NegotiateEncryptionProtocols(host);
                        this.FetchCapabilities();
                    }
                }
            }
        }
    }

comments