SmtpClientSslProtocol Property

Get the negotiated SSL or TLS protocol version.

Definition

Namespace: MailKit.Net.Smtp
Assembly: MailKit (in MailKit.dll) Version: 5.0.0
C#
public override SslProtocols SslProtocol { get; }

Property Value

SslProtocols
The negotiated SSL or TLS protocol version.

Implements

IMailServiceSslProtocol
IMailServiceSslProtocol

Remarks

Gets the negotiated SSL or TLS protocol version once an SSL or TLS connection has been made.

Example

C#
                    public static void PrintSslConnectionInfo (string host, int port)
{
    using (var client = new SmtpClient ()) {
        client.Connect (host, port, SecureSocketOptions.Auto);

        Console.WriteLine ($"Negotiated the following SSL options with {host}:");
        Console.WriteLine ($"        Protocol Version: {client.SslProtocol}");
        Console.WriteLine ($"            Cipher Suite: {client.SslCipherSuite}");

        // Example Log:
        //
        // Negotiated the following SSL options with smtp.gmail.com:
        //         Protocol Version: Tls12
        //             Cipher Suite: TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256

        client.Disconnect (true);
    }
}
                  

See Also