diff --git a/MailKit/IMailService.cs b/MailKit/IMailService.cs index e74e9cb4dd..bfcdc75410 100644 --- a/MailKit/IMailService.cs +++ b/MailKit/IMailService.cs @@ -262,6 +262,24 @@ public CipherSuitesPolicy SslCipherSuitesPolicy { /// The negotiated SSL or TLS hash algorithm strength. int? SslHashStrength { get; } + /// + /// Get the negotiated SSL or TLS key exchange algorithm. + /// + /// + /// Gets the negotiated SSL or TLS key exchange algorithm once an SSL or TLS connection has been made. + /// + /// The negotiated SSL or TLS key exchange algorithm. + ExchangeAlgorithmType? SslKeyExchangeAlgorithm { get; } + + /// + /// Get the negotiated SSL or TLS key exchange algorithm strength. + /// + /// + /// Gets the negotiated SSL or TLS key exchange algorithm strength once an SSL or TLS connection has been made. + /// + /// The negotiated SSL or TLS key exchange algorithm strength. + int? SslKeyExchangeStrength { get; } + /// /// Get or set the timeout for network streaming operations, in milliseconds. /// diff --git a/MailKit/MailService.cs b/MailKit/MailService.cs index 59c0d6f0ef..2e5d8d7af2 100644 --- a/MailKit/MailService.cs +++ b/MailKit/MailService.cs @@ -354,6 +354,28 @@ public abstract int? SslHashStrength { get; } + /// + /// Get the negotiated SSL or TLS key exchange algorithm. + /// + /// + /// Gets the negotiated SSL or TLS key exchange algorithm once an SSL or TLS connection has been made. + /// + /// The negotiated SSL or TLS key exchange algorithm. + public abstract ExchangeAlgorithmType? SslKeyExchangeAlgorithm { + get; + } + + /// + /// Get the negotiated SSL or TLS key exchange algorithm strength. + /// + /// + /// Gets the negotiated SSL or TLS key exchange algorithm strength once an SSL or TLS connection has been made. + /// + /// The negotiated SSL or TLS key exchange algorithm strength. + public abstract int? SslKeyExchangeStrength { + get; + } + /// /// Get whether or not the client is currently authenticated with the mail server. /// diff --git a/MailKit/Net/Imap/ImapClient.cs b/MailKit/Net/Imap/ImapClient.cs index 78ce2ac6bd..59d2364073 100644 --- a/MailKit/Net/Imap/ImapClient.cs +++ b/MailKit/Net/Imap/ImapClient.cs @@ -746,6 +746,38 @@ public override int? SslHashStrength { } } + /// + /// Get the negotiated SSL or TLS key exchange algorithm. + /// + /// + /// Gets the negotiated SSL or TLS key exchange algorithm once an SSL or TLS connection has been made. + /// + /// The negotiated SSL or TLS key exchange algorithm. + public override ExchangeAlgorithmType? SslKeyExchangeAlgorithm { + get { + if (IsSecure && (engine.Stream.Stream is SslStream sslStream)) + return sslStream.KeyExchangeAlgorithm; + + return null; + } + } + + /// + /// Get the negotiated SSL or TLS key exchange algorithm strength. + /// + /// + /// Gets the negotiated SSL or TLS key exchange algorithm strength once an SSL or TLS connection has been made. + /// + /// The negotiated SSL or TLS key exchange algorithm strength. + public override int? SslKeyExchangeStrength { + get { + if (IsSecure && (engine.Stream.Stream is SslStream sslStream)) + return sslStream.KeyExchangeStrength; + + return null; + } + } + /// /// Get whether or not the client is currently authenticated with the IMAP server. /// diff --git a/MailKit/Net/Pop3/Pop3Client.cs b/MailKit/Net/Pop3/Pop3Client.cs index 152781d660..c4fbbf0bd1 100644 --- a/MailKit/Net/Pop3/Pop3Client.cs +++ b/MailKit/Net/Pop3/Pop3Client.cs @@ -487,6 +487,38 @@ public override int? SslHashStrength { } } + /// + /// Get the negotiated SSL or TLS key exchange algorithm. + /// + /// + /// Gets the negotiated SSL or TLS key exchange algorithm once an SSL or TLS connection has been made. + /// + /// The negotiated SSL or TLS key exchange algorithm. + public override ExchangeAlgorithmType? SslKeyExchangeAlgorithm { + get { + if (IsSecure && (engine.Stream.Stream is SslStream sslStream)) + return sslStream.KeyExchangeAlgorithm; + + return null; + } + } + + /// + /// Get the negotiated SSL or TLS key exchange algorithm strength. + /// + /// + /// Gets the negotiated SSL or TLS key exchange algorithm strength once an SSL or TLS connection has been made. + /// + /// The negotiated SSL or TLS key exchange algorithm strength. + public override int? SslKeyExchangeStrength { + get { + if (IsSecure && (engine.Stream.Stream is SslStream sslStream)) + return sslStream.KeyExchangeStrength; + + return null; + } + } + /// /// Get whether or not the client is currently authenticated with the POP3 server. /// diff --git a/MailKit/Net/Smtp/SmtpClient.cs b/MailKit/Net/Smtp/SmtpClient.cs index 3b5358d95e..9a18c78daf 100644 --- a/MailKit/Net/Smtp/SmtpClient.cs +++ b/MailKit/Net/Smtp/SmtpClient.cs @@ -410,6 +410,38 @@ public override int? SslHashStrength { } } + /// + /// Get the negotiated SSL or TLS key exchange algorithm. + /// + /// + /// Gets the negotiated SSL or TLS key exchange algorithm once an SSL or TLS connection has been made. + /// + /// The negotiated SSL or TLS key exchange algorithm. + public override ExchangeAlgorithmType? SslKeyExchangeAlgorithm { + get { + if (IsSecure && (Stream.Stream is SslStream sslStream)) + return sslStream.KeyExchangeAlgorithm; + + return null; + } + } + + /// + /// Get the negotiated SSL or TLS key exchange algorithm strength. + /// + /// + /// Gets the negotiated SSL or TLS key exchange algorithm strength once an SSL or TLS connection has been made. + /// + /// The negotiated SSL or TLS key exchange algorithm strength. + public override int? SslKeyExchangeStrength { + get { + if (IsSecure && (Stream.Stream is SslStream sslStream)) + return sslStream.KeyExchangeStrength; + + return null; + } + } + /// /// Get whether or not the client is currently authenticated with the SMTP server. /// diff --git a/UnitTests/Net/Imap/ImapClientTests.cs b/UnitTests/Net/Imap/ImapClientTests.cs index cc421cbe77..9f3734d220 100644 --- a/UnitTests/Net/Imap/ImapClientTests.cs +++ b/UnitTests/Net/Imap/ImapClientTests.cs @@ -84,9 +84,11 @@ public class ImapClientTests const CipherAlgorithmType GMailCipherAlgorithm = CipherAlgorithmType.Aes128; const int GMailCipherStrength = 128; const HashAlgorithmType GMailHashAlgorithm = HashAlgorithmType.Sha256; + const ExchangeAlgorithmType GMailKeyExchangeAlgorithm = (ExchangeAlgorithmType) 44550; const CipherAlgorithmType GmxDeCipherAlgorithm = CipherAlgorithmType.Aes256; const int GmxDeCipherStrength = 256; const HashAlgorithmType GmxDeHashAlgorithm = HashAlgorithmType.Sha384; + const ExchangeAlgorithmType GmxDeKeyExchangeAlgorithm = (ExchangeAlgorithmType) 44550; static FolderAttributes GetSpecialFolderAttribute (SpecialFolder special) { @@ -384,6 +386,8 @@ public void TestConnectGMail () Assert.AreEqual (GMailCipherStrength, client.SslCipherStrength); Assert.AreEqual (GMailHashAlgorithm, client.SslHashAlgorithm); Assert.AreEqual (0, client.SslHashStrength); + Assert.AreEqual (GMailKeyExchangeAlgorithm, client.SslKeyExchangeAlgorithm); + Assert.AreEqual (255, client.SslKeyExchangeStrength); Assert.IsFalse (client.IsAuthenticated, "Expected the client to not be authenticated"); Assert.AreEqual (1, connected, "ConnectedEvent"); @@ -399,6 +403,8 @@ public void TestConnectGMail () Assert.IsNull (client.SslCipherStrength, "Expected SslCipherStrength to be null after disconnecting"); Assert.IsNull (client.SslHashAlgorithm, "Expected SslHashAlgorithm to be null after disconnecting"); Assert.IsNull (client.SslHashStrength, "Expected SslHashStrength to be null after disconnecting"); + Assert.IsNull (client.SslKeyExchangeAlgorithm, "Expected SslKeyExchangeAlgorithm to be null after disconnecting"); + Assert.IsNull (client.SslKeyExchangeStrength, "Expected SslKeyExchangeStrength to be null after disconnecting"); Assert.AreEqual (1, disconnected, "DisconnectedEvent"); } } @@ -438,6 +444,8 @@ public async Task TestConnectGMailAsync () Assert.AreEqual (GMailCipherStrength, client.SslCipherStrength); Assert.AreEqual (GMailHashAlgorithm, client.SslHashAlgorithm); Assert.AreEqual (0, client.SslHashStrength); + Assert.AreEqual (GMailKeyExchangeAlgorithm, client.SslKeyExchangeAlgorithm); + Assert.AreEqual (255, client.SslKeyExchangeStrength); Assert.IsFalse (client.IsAuthenticated, "Expected the client to not be authenticated"); Assert.AreEqual (1, connected, "ConnectedEvent"); @@ -453,6 +461,8 @@ public async Task TestConnectGMailAsync () Assert.IsNull (client.SslCipherStrength, "Expected SslCipherStrength to be null after disconnecting"); Assert.IsNull (client.SslHashAlgorithm, "Expected SslHashAlgorithm to be null after disconnecting"); Assert.IsNull (client.SslHashStrength, "Expected SslHashStrength to be null after disconnecting"); + Assert.IsNull (client.SslKeyExchangeAlgorithm, "Expected SslKeyExchangeAlgorithm to be null after disconnecting"); + Assert.IsNull (client.SslKeyExchangeStrength, "Expected SslKeyExchangeStrength to be null after disconnecting"); Assert.AreEqual (1, disconnected, "DisconnectedEvent"); } } @@ -508,6 +518,8 @@ public void TestConnectGMailViaProxy () Assert.AreEqual (GMailCipherStrength, client.SslCipherStrength); Assert.AreEqual (GMailHashAlgorithm, client.SslHashAlgorithm); Assert.AreEqual (0, client.SslHashStrength); + Assert.AreEqual (GMailKeyExchangeAlgorithm, client.SslKeyExchangeAlgorithm); + Assert.AreEqual (255, client.SslKeyExchangeStrength); Assert.IsFalse (client.IsAuthenticated, "Expected the client to not be authenticated"); Assert.AreEqual (1, connected, "ConnectedEvent"); @@ -523,6 +535,8 @@ public void TestConnectGMailViaProxy () Assert.IsNull (client.SslCipherStrength, "Expected SslCipherStrength to be null after disconnecting"); Assert.IsNull (client.SslHashAlgorithm, "Expected SslHashAlgorithm to be null after disconnecting"); Assert.IsNull (client.SslHashStrength, "Expected SslHashStrength to be null after disconnecting"); + Assert.IsNull (client.SslKeyExchangeAlgorithm, "Expected SslKeyExchangeAlgorithm to be null after disconnecting"); + Assert.IsNull (client.SslKeyExchangeStrength, "Expected SslKeyExchangeStrength to be null after disconnecting"); Assert.AreEqual (1, disconnected, "DisconnectedEvent"); } } @@ -580,6 +594,8 @@ public async Task TestConnectGMailViaProxyAsync () Assert.AreEqual (GMailCipherStrength, client.SslCipherStrength); Assert.AreEqual (GMailHashAlgorithm, client.SslHashAlgorithm); Assert.AreEqual (0, client.SslHashStrength); + Assert.AreEqual (GMailKeyExchangeAlgorithm, client.SslKeyExchangeAlgorithm); + Assert.AreEqual (255, client.SslKeyExchangeStrength); Assert.IsFalse (client.IsAuthenticated, "Expected the client to not be authenticated"); Assert.AreEqual (1, connected, "ConnectedEvent"); @@ -595,6 +611,8 @@ public async Task TestConnectGMailViaProxyAsync () Assert.IsNull (client.SslCipherStrength, "Expected SslCipherStrength to be null after disconnecting"); Assert.IsNull (client.SslHashAlgorithm, "Expected SslHashAlgorithm to be null after disconnecting"); Assert.IsNull (client.SslHashStrength, "Expected SslHashStrength to be null after disconnecting"); + Assert.IsNull (client.SslKeyExchangeAlgorithm, "Expected SslKeyExchangeAlgorithm to be null after disconnecting"); + Assert.IsNull (client.SslKeyExchangeStrength, "Expected SslKeyExchangeStrength to be null after disconnecting"); Assert.AreEqual (1, disconnected, "DisconnectedEvent"); } } @@ -641,6 +659,8 @@ public void TestConnectGMailSocket () Assert.AreEqual (GMailCipherStrength, client.SslCipherStrength); Assert.AreEqual (GMailHashAlgorithm, client.SslHashAlgorithm); Assert.AreEqual (0, client.SslHashStrength); + Assert.AreEqual (GMailKeyExchangeAlgorithm, client.SslKeyExchangeAlgorithm); + Assert.AreEqual (255, client.SslKeyExchangeStrength); Assert.IsFalse (client.IsAuthenticated, "Expected the client to not be authenticated"); Assert.AreEqual (1, connected, "ConnectedEvent"); @@ -656,6 +676,8 @@ public void TestConnectGMailSocket () Assert.IsNull (client.SslCipherStrength, "Expected SslCipherStrength to be null after disconnecting"); Assert.IsNull (client.SslHashAlgorithm, "Expected SslHashAlgorithm to be null after disconnecting"); Assert.IsNull (client.SslHashStrength, "Expected SslHashStrength to be null after disconnecting"); + Assert.IsNull (client.SslKeyExchangeAlgorithm, "Expected SslKeyExchangeAlgorithm to be null after disconnecting"); + Assert.IsNull (client.SslKeyExchangeStrength, "Expected SslKeyExchangeStrength to be null after disconnecting"); Assert.AreEqual (1, disconnected, "DisconnectedEvent"); } } @@ -701,6 +723,8 @@ public async Task TestConnectGMailSocketAsync () Assert.AreEqual (GMailCipherStrength, client.SslCipherStrength); Assert.AreEqual (GMailHashAlgorithm, client.SslHashAlgorithm); Assert.AreEqual (0, client.SslHashStrength); + Assert.AreEqual (GMailKeyExchangeAlgorithm, client.SslKeyExchangeAlgorithm); + Assert.AreEqual (255, client.SslKeyExchangeStrength); Assert.IsFalse (client.IsAuthenticated, "Expected the client to not be authenticated"); Assert.AreEqual (1, connected, "ConnectedEvent"); @@ -716,6 +740,8 @@ public async Task TestConnectGMailSocketAsync () Assert.IsNull (client.SslCipherStrength, "Expected SslCipherStrength to be null after disconnecting"); Assert.IsNull (client.SslHashAlgorithm, "Expected SslHashAlgorithm to be null after disconnecting"); Assert.IsNull (client.SslHashStrength, "Expected SslHashStrength to be null after disconnecting"); + Assert.IsNull (client.SslKeyExchangeAlgorithm, "Expected SslKeyExchangeAlgorithm to be null after disconnecting"); + Assert.IsNull (client.SslKeyExchangeStrength, "Expected SslKeyExchangeStrength to be null after disconnecting"); Assert.AreEqual (1, disconnected, "DisconnectedEvent"); } } @@ -757,6 +783,8 @@ public void TestConnectGmxDe () Assert.AreEqual (GmxDeCipherStrength, client.SslCipherStrength); Assert.AreEqual (GmxDeHashAlgorithm, client.SslHashAlgorithm); Assert.AreEqual (0, client.SslHashStrength); + Assert.AreEqual (GmxDeKeyExchangeAlgorithm, client.SslKeyExchangeAlgorithm); + Assert.AreEqual (255, client.SslKeyExchangeStrength); Assert.IsFalse (client.IsAuthenticated, "Expected the client to not be authenticated"); Assert.AreEqual (1, connected, "ConnectedEvent"); @@ -770,6 +798,8 @@ public void TestConnectGmxDe () Assert.IsNull (client.SslCipherStrength, "Expected SslCipherStrength to be null after disconnecting"); Assert.IsNull (client.SslHashAlgorithm, "Expected SslHashAlgorithm to be null after disconnecting"); Assert.IsNull (client.SslHashStrength, "Expected SslHashStrength to be null after disconnecting"); + Assert.IsNull (client.SslKeyExchangeAlgorithm, "Expected SslKeyExchangeAlgorithm to be null after disconnecting"); + Assert.IsNull (client.SslKeyExchangeStrength, "Expected SslKeyExchangeStrength to be null after disconnecting"); Assert.AreEqual (1, disconnected, "DisconnectedEvent"); } } @@ -812,6 +842,8 @@ public async Task TestConnectGmxDeAsync () Assert.AreEqual (GmxDeCipherStrength, client.SslCipherStrength); Assert.AreEqual (GmxDeHashAlgorithm, client.SslHashAlgorithm); Assert.AreEqual (0, client.SslHashStrength); + Assert.AreEqual (GmxDeKeyExchangeAlgorithm, client.SslKeyExchangeAlgorithm); + Assert.AreEqual (255, client.SslKeyExchangeStrength); Assert.IsFalse (client.IsAuthenticated, "Expected the client to not be authenticated"); Assert.AreEqual (1, connected, "ConnectedEvent"); @@ -825,6 +857,8 @@ public async Task TestConnectGmxDeAsync () Assert.IsNull (client.SslCipherStrength, "Expected SslCipherStrength to be null after disconnecting"); Assert.IsNull (client.SslHashAlgorithm, "Expected SslHashAlgorithm to be null after disconnecting"); Assert.IsNull (client.SslHashStrength, "Expected SslHashStrength to be null after disconnecting"); + Assert.IsNull (client.SslKeyExchangeAlgorithm, "Expected SslKeyExchangeAlgorithm to be null after disconnecting"); + Assert.IsNull (client.SslKeyExchangeStrength, "Expected SslKeyExchangeStrength to be null after disconnecting"); Assert.AreEqual (1, disconnected, "DisconnectedEvent"); } } @@ -867,6 +901,8 @@ public void TestConnectGmxDeSocket () Assert.AreEqual (GmxDeCipherStrength, client.SslCipherStrength); Assert.AreEqual (GmxDeHashAlgorithm, client.SslHashAlgorithm); Assert.AreEqual (0, client.SslHashStrength); + Assert.AreEqual (GmxDeKeyExchangeAlgorithm, client.SslKeyExchangeAlgorithm); + Assert.AreEqual (255, client.SslKeyExchangeStrength); Assert.IsFalse (client.IsAuthenticated, "Expected the client to not be authenticated"); Assert.AreEqual (1, connected, "ConnectedEvent"); @@ -880,6 +916,8 @@ public void TestConnectGmxDeSocket () Assert.IsNull (client.SslCipherStrength, "Expected SslCipherStrength to be null after disconnecting"); Assert.IsNull (client.SslHashAlgorithm, "Expected SslHashAlgorithm to be null after disconnecting"); Assert.IsNull (client.SslHashStrength, "Expected SslHashStrength to be null after disconnecting"); + Assert.IsNull (client.SslKeyExchangeAlgorithm, "Expected SslKeyExchangeAlgorithm to be null after disconnecting"); + Assert.IsNull (client.SslKeyExchangeStrength, "Expected SslKeyExchangeStrength to be null after disconnecting"); Assert.AreEqual (1, disconnected, "DisconnectedEvent"); } } @@ -922,6 +960,8 @@ public async Task TestConnectGmxDeSocketAsync () Assert.AreEqual (GmxDeCipherStrength, client.SslCipherStrength); Assert.AreEqual (GmxDeHashAlgorithm, client.SslHashAlgorithm); Assert.AreEqual (0, client.SslHashStrength); + Assert.AreEqual (GmxDeKeyExchangeAlgorithm, client.SslKeyExchangeAlgorithm); + Assert.AreEqual (255, client.SslKeyExchangeStrength); Assert.IsFalse (client.IsAuthenticated, "Expected the client to not be authenticated"); Assert.AreEqual (1, connected, "ConnectedEvent"); @@ -935,6 +975,8 @@ public async Task TestConnectGmxDeSocketAsync () Assert.IsNull (client.SslCipherStrength, "Expected SslCipherStrength to be null after disconnecting"); Assert.IsNull (client.SslHashAlgorithm, "Expected SslHashAlgorithm to be null after disconnecting"); Assert.IsNull (client.SslHashStrength, "Expected SslHashStrength to be null after disconnecting"); + Assert.IsNull (client.SslKeyExchangeAlgorithm, "Expected SslKeyExchangeAlgorithm to be null after disconnecting"); + Assert.IsNull (client.SslKeyExchangeStrength, "Expected SslKeyExchangeStrength to be null after disconnecting"); Assert.AreEqual (1, disconnected, "DisconnectedEvent"); } } diff --git a/UnitTests/Net/Pop3/Pop3ClientTests.cs b/UnitTests/Net/Pop3/Pop3ClientTests.cs index cba73bb8fc..5d0a3f341f 100644 --- a/UnitTests/Net/Pop3/Pop3ClientTests.cs +++ b/UnitTests/Net/Pop3/Pop3ClientTests.cs @@ -76,9 +76,11 @@ public class Pop3ClientTests const CipherAlgorithmType GMailCipherAlgorithm = CipherAlgorithmType.Aes128; const int GMailCipherStrength = 128; const HashAlgorithmType GMailHashAlgorithm = HashAlgorithmType.Sha256; + const ExchangeAlgorithmType GMailKeyExchangeAlgorithm = (ExchangeAlgorithmType) 44550; const CipherAlgorithmType GmxDeCipherAlgorithm = CipherAlgorithmType.Aes256; const int GmxDeCipherStrength = 256; const HashAlgorithmType GmxDeHashAlgorithm = HashAlgorithmType.Sha384; + const ExchangeAlgorithmType GmxDeKeyExchangeAlgorithm = (ExchangeAlgorithmType) 44550; static string HexEncode (byte[] digest) { @@ -538,6 +540,8 @@ public void TestConnectGMail () Assert.AreEqual (GMailCipherStrength, client.SslCipherStrength); Assert.AreEqual (GMailHashAlgorithm, client.SslHashAlgorithm); Assert.AreEqual (0, client.SslHashStrength); + Assert.AreEqual (GMailKeyExchangeAlgorithm, client.SslKeyExchangeAlgorithm); + Assert.AreEqual (255, client.SslKeyExchangeStrength); Assert.IsFalse (client.IsAuthenticated, "Expected the client to not be authenticated"); Assert.AreEqual (1, connected, "ConnectedEvent"); @@ -553,6 +557,8 @@ public void TestConnectGMail () Assert.IsNull (client.SslCipherStrength, "Expected SslCipherStrength to be null after disconnecting"); Assert.IsNull (client.SslHashAlgorithm, "Expected SslHashAlgorithm to be null after disconnecting"); Assert.IsNull (client.SslHashStrength, "Expected SslHashStrength to be null after disconnecting"); + Assert.IsNull (client.SslKeyExchangeAlgorithm, "Expected SslKeyExchangeAlgorithm to be null after disconnecting"); + Assert.IsNull (client.SslKeyExchangeStrength, "Expected SslKeyExchangeStrength to be null after disconnecting"); Assert.AreEqual (1, disconnected, "DisconnectedEvent"); } } @@ -592,6 +598,8 @@ public async Task TestConnectGMailAsync () Assert.AreEqual (GMailCipherStrength, client.SslCipherStrength); Assert.AreEqual (GMailHashAlgorithm, client.SslHashAlgorithm); Assert.AreEqual (0, client.SslHashStrength); + Assert.AreEqual (GMailKeyExchangeAlgorithm, client.SslKeyExchangeAlgorithm); + Assert.AreEqual (255, client.SslKeyExchangeStrength); Assert.IsFalse (client.IsAuthenticated, "Expected the client to not be authenticated"); Assert.AreEqual (1, connected, "ConnectedEvent"); @@ -607,6 +615,8 @@ public async Task TestConnectGMailAsync () Assert.IsNull (client.SslCipherStrength, "Expected SslCipherStrength to be null after disconnecting"); Assert.IsNull (client.SslHashAlgorithm, "Expected SslHashAlgorithm to be null after disconnecting"); Assert.IsNull (client.SslHashStrength, "Expected SslHashStrength to be null after disconnecting"); + Assert.IsNull (client.SslKeyExchangeAlgorithm, "Expected SslKeyExchangeAlgorithm to be null after disconnecting"); + Assert.IsNull (client.SslKeyExchangeStrength, "Expected SslKeyExchangeStrength to be null after disconnecting"); Assert.AreEqual (1, disconnected, "DisconnectedEvent"); } } @@ -662,6 +672,8 @@ public void TestConnectGMailViaProxy () Assert.AreEqual (GMailCipherStrength, client.SslCipherStrength); Assert.AreEqual (GMailHashAlgorithm, client.SslHashAlgorithm); Assert.AreEqual (0, client.SslHashStrength); + Assert.AreEqual (GMailKeyExchangeAlgorithm, client.SslKeyExchangeAlgorithm); + Assert.AreEqual (255, client.SslKeyExchangeStrength); Assert.IsFalse (client.IsAuthenticated, "Expected the client to not be authenticated"); Assert.AreEqual (1, connected, "ConnectedEvent"); @@ -677,6 +689,8 @@ public void TestConnectGMailViaProxy () Assert.IsNull (client.SslCipherStrength, "Expected SslCipherStrength to be null after disconnecting"); Assert.IsNull (client.SslHashAlgorithm, "Expected SslHashAlgorithm to be null after disconnecting"); Assert.IsNull (client.SslHashStrength, "Expected SslHashStrength to be null after disconnecting"); + Assert.IsNull (client.SslKeyExchangeAlgorithm, "Expected SslKeyExchangeAlgorithm to be null after disconnecting"); + Assert.IsNull (client.SslKeyExchangeStrength, "Expected SslKeyExchangeStrength to be null after disconnecting"); Assert.AreEqual (1, disconnected, "DisconnectedEvent"); } } @@ -733,6 +747,8 @@ public async Task TestConnectGMailViaProxyAsync () Assert.AreEqual (GMailCipherStrength, client.SslCipherStrength); Assert.AreEqual (GMailHashAlgorithm, client.SslHashAlgorithm); Assert.AreEqual (0, client.SslHashStrength); + Assert.AreEqual (GMailKeyExchangeAlgorithm, client.SslKeyExchangeAlgorithm); + Assert.AreEqual (255, client.SslKeyExchangeStrength); Assert.IsFalse (client.IsAuthenticated, "Expected the client to not be authenticated"); Assert.AreEqual (1, connected, "ConnectedEvent"); @@ -748,6 +764,8 @@ public async Task TestConnectGMailViaProxyAsync () Assert.IsNull (client.SslCipherStrength, "Expected SslCipherStrength to be null after disconnecting"); Assert.IsNull (client.SslHashAlgorithm, "Expected SslHashAlgorithm to be null after disconnecting"); Assert.IsNull (client.SslHashStrength, "Expected SslHashStrength to be null after disconnecting"); + Assert.IsNull (client.SslKeyExchangeAlgorithm, "Expected SslKeyExchangeAlgorithm to be null after disconnecting"); + Assert.IsNull (client.SslKeyExchangeStrength, "Expected SslKeyExchangeStrength to be null after disconnecting"); Assert.AreEqual (1, disconnected, "DisconnectedEvent"); } } @@ -794,6 +812,8 @@ public void TestConnectGMailSocket () Assert.AreEqual (GMailCipherStrength, client.SslCipherStrength); Assert.AreEqual (GMailHashAlgorithm, client.SslHashAlgorithm); Assert.AreEqual (0, client.SslHashStrength); + Assert.AreEqual (GMailKeyExchangeAlgorithm, client.SslKeyExchangeAlgorithm); + Assert.AreEqual (255, client.SslKeyExchangeStrength); Assert.IsFalse (client.IsAuthenticated, "Expected the client to not be authenticated"); Assert.AreEqual (1, connected, "ConnectedEvent"); @@ -809,6 +829,8 @@ public void TestConnectGMailSocket () Assert.IsNull (client.SslCipherStrength, "Expected SslCipherStrength to be null after disconnecting"); Assert.IsNull (client.SslHashAlgorithm, "Expected SslHashAlgorithm to be null after disconnecting"); Assert.IsNull (client.SslHashStrength, "Expected SslHashStrength to be null after disconnecting"); + Assert.IsNull (client.SslKeyExchangeAlgorithm, "Expected SslKeyExchangeAlgorithm to be null after disconnecting"); + Assert.IsNull (client.SslKeyExchangeStrength, "Expected SslKeyExchangeStrength to be null after disconnecting"); Assert.AreEqual (1, disconnected, "DisconnectedEvent"); } } @@ -854,6 +876,8 @@ public async Task TestConnectGMailSocketAsync () Assert.AreEqual (GMailCipherStrength, client.SslCipherStrength); Assert.AreEqual (GMailHashAlgorithm, client.SslHashAlgorithm); Assert.AreEqual (0, client.SslHashStrength); + Assert.AreEqual (GMailKeyExchangeAlgorithm, client.SslKeyExchangeAlgorithm); + Assert.AreEqual (255, client.SslKeyExchangeStrength); Assert.IsFalse (client.IsAuthenticated, "Expected the client to not be authenticated"); Assert.AreEqual (1, connected, "ConnectedEvent"); @@ -869,6 +893,8 @@ public async Task TestConnectGMailSocketAsync () Assert.IsNull (client.SslCipherStrength, "Expected SslCipherStrength to be null after disconnecting"); Assert.IsNull (client.SslHashAlgorithm, "Expected SslHashAlgorithm to be null after disconnecting"); Assert.IsNull (client.SslHashStrength, "Expected SslHashStrength to be null after disconnecting"); + Assert.IsNull (client.SslKeyExchangeAlgorithm, "Expected SslKeyExchangeAlgorithm to be null after disconnecting"); + Assert.IsNull (client.SslKeyExchangeStrength, "Expected SslKeyExchangeStrength to be null after disconnecting"); Assert.AreEqual (1, disconnected, "DisconnectedEvent"); } } @@ -910,6 +936,8 @@ public void TestConnectGmxDe () Assert.AreEqual (GmxDeCipherStrength, client.SslCipherStrength); Assert.AreEqual (GmxDeHashAlgorithm, client.SslHashAlgorithm); Assert.AreEqual (0, client.SslHashStrength); + Assert.AreEqual (GmxDeKeyExchangeAlgorithm, client.SslKeyExchangeAlgorithm); + Assert.AreEqual (255, client.SslKeyExchangeStrength); Assert.IsFalse (client.IsAuthenticated, "Expected the client to not be authenticated"); Assert.AreEqual (1, connected, "ConnectedEvent"); @@ -923,6 +951,8 @@ public void TestConnectGmxDe () Assert.IsNull (client.SslCipherStrength, "Expected SslCipherStrength to be null after disconnecting"); Assert.IsNull (client.SslHashAlgorithm, "Expected SslHashAlgorithm to be null after disconnecting"); Assert.IsNull (client.SslHashStrength, "Expected SslHashStrength to be null after disconnecting"); + Assert.IsNull (client.SslKeyExchangeAlgorithm, "Expected SslKeyExchangeAlgorithm to be null after disconnecting"); + Assert.IsNull (client.SslKeyExchangeStrength, "Expected SslKeyExchangeStrength to be null after disconnecting"); Assert.AreEqual (1, disconnected, "DisconnectedEvent"); } } @@ -965,6 +995,8 @@ public async Task TestConnectGmxDeAsync () Assert.AreEqual (GmxDeCipherStrength, client.SslCipherStrength); Assert.AreEqual (GmxDeHashAlgorithm, client.SslHashAlgorithm); Assert.AreEqual (0, client.SslHashStrength); + Assert.AreEqual (GmxDeKeyExchangeAlgorithm, client.SslKeyExchangeAlgorithm); + Assert.AreEqual (255, client.SslKeyExchangeStrength); Assert.IsFalse (client.IsAuthenticated, "Expected the client to not be authenticated"); Assert.AreEqual (1, connected, "ConnectedEvent"); @@ -978,6 +1010,8 @@ public async Task TestConnectGmxDeAsync () Assert.IsNull (client.SslCipherStrength, "Expected SslCipherStrength to be null after disconnecting"); Assert.IsNull (client.SslHashAlgorithm, "Expected SslHashAlgorithm to be null after disconnecting"); Assert.IsNull (client.SslHashStrength, "Expected SslHashStrength to be null after disconnecting"); + Assert.IsNull (client.SslKeyExchangeAlgorithm, "Expected SslKeyExchangeAlgorithm to be null after disconnecting"); + Assert.IsNull (client.SslKeyExchangeStrength, "Expected SslKeyExchangeStrength to be null after disconnecting"); Assert.AreEqual (1, disconnected, "DisconnectedEvent"); } } @@ -1020,6 +1054,8 @@ public void TestConnectGmxDeSocket () Assert.AreEqual (GmxDeCipherStrength, client.SslCipherStrength); Assert.AreEqual (GmxDeHashAlgorithm, client.SslHashAlgorithm); Assert.AreEqual (0, client.SslHashStrength); + Assert.AreEqual (GmxDeKeyExchangeAlgorithm, client.SslKeyExchangeAlgorithm); + Assert.AreEqual (255, client.SslKeyExchangeStrength); Assert.IsFalse (client.IsAuthenticated, "Expected the client to not be authenticated"); Assert.AreEqual (1, connected, "ConnectedEvent"); @@ -1033,6 +1069,8 @@ public void TestConnectGmxDeSocket () Assert.IsNull (client.SslCipherStrength, "Expected SslCipherStrength to be null after disconnecting"); Assert.IsNull (client.SslHashAlgorithm, "Expected SslHashAlgorithm to be null after disconnecting"); Assert.IsNull (client.SslHashStrength, "Expected SslHashStrength to be null after disconnecting"); + Assert.IsNull (client.SslKeyExchangeAlgorithm, "Expected SslKeyExchangeAlgorithm to be null after disconnecting"); + Assert.IsNull (client.SslKeyExchangeStrength, "Expected SslKeyExchangeStrength to be null after disconnecting"); Assert.AreEqual (1, disconnected, "DisconnectedEvent"); } } @@ -1075,6 +1113,8 @@ public async Task TestConnectGmxDeSocketAsync () Assert.AreEqual (GmxDeCipherStrength, client.SslCipherStrength); Assert.AreEqual (GmxDeHashAlgorithm, client.SslHashAlgorithm); Assert.AreEqual (0, client.SslHashStrength); + Assert.AreEqual (GmxDeKeyExchangeAlgorithm, client.SslKeyExchangeAlgorithm); + Assert.AreEqual (255, client.SslKeyExchangeStrength); Assert.IsFalse (client.IsAuthenticated, "Expected the client to not be authenticated"); Assert.AreEqual (1, connected, "ConnectedEvent"); @@ -1088,6 +1128,8 @@ public async Task TestConnectGmxDeSocketAsync () Assert.IsNull (client.SslCipherStrength, "Expected SslCipherStrength to be null after disconnecting"); Assert.IsNull (client.SslHashAlgorithm, "Expected SslHashAlgorithm to be null after disconnecting"); Assert.IsNull (client.SslHashStrength, "Expected SslHashStrength to be null after disconnecting"); + Assert.IsNull (client.SslKeyExchangeAlgorithm, "Expected SslKeyExchangeAlgorithm to be null after disconnecting"); + Assert.IsNull (client.SslKeyExchangeStrength, "Expected SslKeyExchangeStrength to be null after disconnecting"); Assert.AreEqual (1, disconnected, "DisconnectedEvent"); } } diff --git a/UnitTests/Net/Smtp/SmtpClientTests.cs b/UnitTests/Net/Smtp/SmtpClientTests.cs index bf31b1a602..737ae584c3 100644 --- a/UnitTests/Net/Smtp/SmtpClientTests.cs +++ b/UnitTests/Net/Smtp/SmtpClientTests.cs @@ -57,9 +57,11 @@ public class SmtpClientTests const CipherAlgorithmType GMailCipherAlgorithm = CipherAlgorithmType.Aes128; const int GMailCipherStrength = 128; const HashAlgorithmType GMailHashAlgorithm = HashAlgorithmType.Sha256; + const ExchangeAlgorithmType GMailKeyExchangeAlgorithm = (ExchangeAlgorithmType) 44550; const CipherAlgorithmType YahooCipherAlgorithm = CipherAlgorithmType.Aes128; const int YahooCipherStrength = 128; const HashAlgorithmType YahooHashAlgorithm = HashAlgorithmType.Sha256; + const ExchangeAlgorithmType YahooKeyExchangeAlgorithm = (ExchangeAlgorithmType) 44550; class MyProgress : ITransferProgress { @@ -559,6 +561,8 @@ public void TestConnectGMail () Assert.AreEqual (GMailCipherStrength, client.SslCipherStrength); Assert.AreEqual (GMailHashAlgorithm, client.SslHashAlgorithm); Assert.AreEqual (0, client.SslHashStrength); + Assert.AreEqual (GMailKeyExchangeAlgorithm, client.SslKeyExchangeAlgorithm); + Assert.AreEqual (255, client.SslKeyExchangeStrength); Assert.IsFalse (client.IsAuthenticated, "Expected the client to not be authenticated"); Assert.AreEqual (1, connected, "ConnectedEvent"); @@ -569,6 +573,13 @@ public void TestConnectGMail () Assert.IsFalse (client.IsSecure, "Expected IsSecure to be false after disconnecting"); Assert.IsFalse (client.IsEncrypted, "Expected IsEncrypted to be false after disconnecting"); Assert.IsFalse (client.IsSigned, "Expected IsSigned to be false after disconnecting"); + Assert.AreEqual (SslProtocols.None, client.SslProtocol, "Expected SslProtocol to be None after disconnecting"); + Assert.IsNull (client.SslCipherAlgorithm, "Expected SslCipherAlgorithm to be null after disconnecting"); + Assert.IsNull (client.SslCipherStrength, "Expected SslCipherStrength to be null after disconnecting"); + Assert.IsNull (client.SslHashAlgorithm, "Expected SslHashAlgorithm to be null after disconnecting"); + Assert.IsNull (client.SslHashStrength, "Expected SslHashStrength to be null after disconnecting"); + Assert.IsNull (client.SslKeyExchangeAlgorithm, "Expected SslKeyExchangeAlgorithm to be null after disconnecting"); + Assert.IsNull (client.SslKeyExchangeStrength, "Expected SslKeyExchangeStrength to be null after disconnecting"); Assert.AreEqual (1, disconnected, "DisconnectedEvent"); } } @@ -608,6 +619,8 @@ public async Task TestConnectGMailAsync () Assert.AreEqual (GMailCipherStrength, client.SslCipherStrength); Assert.AreEqual (GMailHashAlgorithm, client.SslHashAlgorithm); Assert.AreEqual (0, client.SslHashStrength); + Assert.AreEqual (GMailKeyExchangeAlgorithm, client.SslKeyExchangeAlgorithm); + Assert.AreEqual (255, client.SslKeyExchangeStrength); Assert.IsFalse (client.IsAuthenticated, "Expected the client to not be authenticated"); Assert.AreEqual (1, connected, "ConnectedEvent"); @@ -618,6 +631,13 @@ public async Task TestConnectGMailAsync () Assert.IsFalse (client.IsSecure, "Expected IsSecure to be false after disconnecting"); Assert.IsFalse (client.IsEncrypted, "Expected IsEncrypted to be false after disconnecting"); Assert.IsFalse (client.IsSigned, "Expected IsSigned to be false after disconnecting"); + Assert.AreEqual (SslProtocols.None, client.SslProtocol, "Expected SslProtocol to be None after disconnecting"); + Assert.IsNull (client.SslCipherAlgorithm, "Expected SslCipherAlgorithm to be null after disconnecting"); + Assert.IsNull (client.SslCipherStrength, "Expected SslCipherStrength to be null after disconnecting"); + Assert.IsNull (client.SslHashAlgorithm, "Expected SslHashAlgorithm to be null after disconnecting"); + Assert.IsNull (client.SslHashStrength, "Expected SslHashStrength to be null after disconnecting"); + Assert.IsNull (client.SslKeyExchangeAlgorithm, "Expected SslKeyExchangeAlgorithm to be null after disconnecting"); + Assert.IsNull (client.SslKeyExchangeStrength, "Expected SslKeyExchangeStrength to be null after disconnecting"); Assert.AreEqual (1, disconnected, "DisconnectedEvent"); } } @@ -673,6 +693,8 @@ public void TestConnectGMailViaProxy () Assert.AreEqual (GMailCipherStrength, client.SslCipherStrength); Assert.AreEqual (GMailHashAlgorithm, client.SslHashAlgorithm); Assert.AreEqual (0, client.SslHashStrength); + Assert.AreEqual (GMailKeyExchangeAlgorithm, client.SslKeyExchangeAlgorithm); + Assert.AreEqual (255, client.SslKeyExchangeStrength); Assert.IsFalse (client.IsAuthenticated, "Expected the client to not be authenticated"); Assert.AreEqual (1, connected, "ConnectedEvent"); @@ -683,6 +705,13 @@ public void TestConnectGMailViaProxy () Assert.IsFalse (client.IsSecure, "Expected IsSecure to be false after disconnecting"); Assert.IsFalse (client.IsEncrypted, "Expected IsEncrypted to be false after disconnecting"); Assert.IsFalse (client.IsSigned, "Expected IsSigned to be false after disconnecting"); + Assert.AreEqual (SslProtocols.None, client.SslProtocol, "Expected SslProtocol to be None after disconnecting"); + Assert.IsNull (client.SslCipherAlgorithm, "Expected SslCipherAlgorithm to be null after disconnecting"); + Assert.IsNull (client.SslCipherStrength, "Expected SslCipherStrength to be null after disconnecting"); + Assert.IsNull (client.SslHashAlgorithm, "Expected SslHashAlgorithm to be null after disconnecting"); + Assert.IsNull (client.SslHashStrength, "Expected SslHashStrength to be null after disconnecting"); + Assert.IsNull (client.SslKeyExchangeAlgorithm, "Expected SslKeyExchangeAlgorithm to be null after disconnecting"); + Assert.IsNull (client.SslKeyExchangeStrength, "Expected SslKeyExchangeStrength to be null after disconnecting"); Assert.AreEqual (1, disconnected, "DisconnectedEvent"); } } @@ -739,6 +768,8 @@ public async Task TestConnectGMailViaProxyAsync () Assert.AreEqual (GMailCipherStrength, client.SslCipherStrength); Assert.AreEqual (GMailHashAlgorithm, client.SslHashAlgorithm); Assert.AreEqual (0, client.SslHashStrength); + Assert.AreEqual (GMailKeyExchangeAlgorithm, client.SslKeyExchangeAlgorithm); + Assert.AreEqual (255, client.SslKeyExchangeStrength); Assert.IsFalse (client.IsAuthenticated, "Expected the client to not be authenticated"); Assert.AreEqual (1, connected, "ConnectedEvent"); @@ -749,6 +780,13 @@ public async Task TestConnectGMailViaProxyAsync () Assert.IsFalse (client.IsSecure, "Expected IsSecure to be false after disconnecting"); Assert.IsFalse (client.IsEncrypted, "Expected IsEncrypted to be false after disconnecting"); Assert.IsFalse (client.IsSigned, "Expected IsSigned to be false after disconnecting"); + Assert.AreEqual (SslProtocols.None, client.SslProtocol, "Expected SslProtocol to be None after disconnecting"); + Assert.IsNull (client.SslCipherAlgorithm, "Expected SslCipherAlgorithm to be null after disconnecting"); + Assert.IsNull (client.SslCipherStrength, "Expected SslCipherStrength to be null after disconnecting"); + Assert.IsNull (client.SslHashAlgorithm, "Expected SslHashAlgorithm to be null after disconnecting"); + Assert.IsNull (client.SslHashStrength, "Expected SslHashStrength to be null after disconnecting"); + Assert.IsNull (client.SslKeyExchangeAlgorithm, "Expected SslKeyExchangeAlgorithm to be null after disconnecting"); + Assert.IsNull (client.SslKeyExchangeStrength, "Expected SslKeyExchangeStrength to be null after disconnecting"); Assert.AreEqual (1, disconnected, "DisconnectedEvent"); } } @@ -795,6 +833,8 @@ public void TestConnectGMailSocket () Assert.AreEqual (GMailCipherStrength, client.SslCipherStrength); Assert.AreEqual (GMailHashAlgorithm, client.SslHashAlgorithm); Assert.AreEqual (0, client.SslHashStrength); + Assert.AreEqual (GMailKeyExchangeAlgorithm, client.SslKeyExchangeAlgorithm); + Assert.AreEqual (255, client.SslKeyExchangeStrength); Assert.IsFalse (client.IsAuthenticated, "Expected the client to not be authenticated"); Assert.AreEqual (1, connected, "ConnectedEvent"); @@ -805,6 +845,13 @@ public void TestConnectGMailSocket () Assert.IsFalse (client.IsSecure, "Expected IsSecure to be false after disconnecting"); Assert.IsFalse (client.IsEncrypted, "Expected IsEncrypted to be false after disconnecting"); Assert.IsFalse (client.IsSigned, "Expected IsSigned to be false after disconnecting"); + Assert.AreEqual (SslProtocols.None, client.SslProtocol, "Expected SslProtocol to be None after disconnecting"); + Assert.IsNull (client.SslCipherAlgorithm, "Expected SslCipherAlgorithm to be null after disconnecting"); + Assert.IsNull (client.SslCipherStrength, "Expected SslCipherStrength to be null after disconnecting"); + Assert.IsNull (client.SslHashAlgorithm, "Expected SslHashAlgorithm to be null after disconnecting"); + Assert.IsNull (client.SslHashStrength, "Expected SslHashStrength to be null after disconnecting"); + Assert.IsNull (client.SslKeyExchangeAlgorithm, "Expected SslKeyExchangeAlgorithm to be null after disconnecting"); + Assert.IsNull (client.SslKeyExchangeStrength, "Expected SslKeyExchangeStrength to be null after disconnecting"); Assert.AreEqual (1, disconnected, "DisconnectedEvent"); } } @@ -850,6 +897,8 @@ public async Task TestConnectGMailSocketAsync () Assert.AreEqual (GMailCipherStrength, client.SslCipherStrength); Assert.AreEqual (GMailHashAlgorithm, client.SslHashAlgorithm); Assert.AreEqual (0, client.SslHashStrength); + Assert.AreEqual (GMailKeyExchangeAlgorithm, client.SslKeyExchangeAlgorithm); + Assert.AreEqual (255, client.SslKeyExchangeStrength); Assert.IsFalse (client.IsAuthenticated, "Expected the client to not be authenticated"); Assert.AreEqual (1, connected, "ConnectedEvent"); @@ -860,6 +909,13 @@ public async Task TestConnectGMailSocketAsync () Assert.IsFalse (client.IsSecure, "Expected IsSecure to be false after disconnecting"); Assert.IsFalse (client.IsEncrypted, "Expected IsEncrypted to be false after disconnecting"); Assert.IsFalse (client.IsSigned, "Expected IsSigned to be false after disconnecting"); + Assert.AreEqual (SslProtocols.None, client.SslProtocol, "Expected SslProtocol to be None after disconnecting"); + Assert.IsNull (client.SslCipherAlgorithm, "Expected SslCipherAlgorithm to be null after disconnecting"); + Assert.IsNull (client.SslCipherStrength, "Expected SslCipherStrength to be null after disconnecting"); + Assert.IsNull (client.SslHashAlgorithm, "Expected SslHashAlgorithm to be null after disconnecting"); + Assert.IsNull (client.SslHashStrength, "Expected SslHashStrength to be null after disconnecting"); + Assert.IsNull (client.SslKeyExchangeAlgorithm, "Expected SslKeyExchangeAlgorithm to be null after disconnecting"); + Assert.IsNull (client.SslKeyExchangeStrength, "Expected SslKeyExchangeStrength to be null after disconnecting"); Assert.AreEqual (1, disconnected, "DisconnectedEvent"); } } @@ -901,6 +957,8 @@ public void TestConnectYahoo () Assert.AreEqual (YahooCipherStrength, client.SslCipherStrength); Assert.AreEqual (YahooHashAlgorithm, client.SslHashAlgorithm); Assert.AreEqual (0, client.SslHashStrength); + Assert.AreEqual (YahooKeyExchangeAlgorithm, client.SslKeyExchangeAlgorithm); + Assert.AreEqual (255, client.SslKeyExchangeStrength); Assert.IsFalse (client.IsAuthenticated, "Expected the client to not be authenticated"); Assert.AreEqual (1, connected, "ConnectedEvent"); @@ -909,6 +967,13 @@ public void TestConnectYahoo () Assert.IsFalse (client.IsSecure, "Expected IsSecure to be false after disconnecting"); Assert.IsFalse (client.IsEncrypted, "Expected IsEncrypted to be false after disconnecting"); Assert.IsFalse (client.IsSigned, "Expected IsSigned to be false after disconnecting"); + Assert.AreEqual (SslProtocols.None, client.SslProtocol, "Expected SslProtocol to be None after disconnecting"); + Assert.IsNull (client.SslCipherAlgorithm, "Expected SslCipherAlgorithm to be null after disconnecting"); + Assert.IsNull (client.SslCipherStrength, "Expected SslCipherStrength to be null after disconnecting"); + Assert.IsNull (client.SslHashAlgorithm, "Expected SslHashAlgorithm to be null after disconnecting"); + Assert.IsNull (client.SslHashStrength, "Expected SslHashStrength to be null after disconnecting"); + Assert.IsNull (client.SslKeyExchangeAlgorithm, "Expected SslKeyExchangeAlgorithm to be null after disconnecting"); + Assert.IsNull (client.SslKeyExchangeStrength, "Expected SslKeyExchangeStrength to be null after disconnecting"); Assert.AreEqual (1, disconnected, "DisconnectedEvent"); } } @@ -951,6 +1016,8 @@ public async Task TestConnectYahooAsync () Assert.AreEqual (YahooCipherStrength, client.SslCipherStrength); Assert.AreEqual (YahooHashAlgorithm, client.SslHashAlgorithm); Assert.AreEqual (0, client.SslHashStrength); + Assert.AreEqual (YahooKeyExchangeAlgorithm, client.SslKeyExchangeAlgorithm); + Assert.AreEqual (255, client.SslKeyExchangeStrength); Assert.IsFalse (client.IsAuthenticated, "Expected the client to not be authenticated"); Assert.AreEqual (1, connected, "ConnectedEvent"); @@ -959,6 +1026,13 @@ public async Task TestConnectYahooAsync () Assert.IsFalse (client.IsSecure, "Expected IsSecure to be false after disconnecting"); Assert.IsFalse (client.IsEncrypted, "Expected IsEncrypted to be false after disconnecting"); Assert.IsFalse (client.IsSigned, "Expected IsSigned to be false after disconnecting"); + Assert.AreEqual (SslProtocols.None, client.SslProtocol, "Expected SslProtocol to be None after disconnecting"); + Assert.IsNull (client.SslCipherAlgorithm, "Expected SslCipherAlgorithm to be null after disconnecting"); + Assert.IsNull (client.SslCipherStrength, "Expected SslCipherStrength to be null after disconnecting"); + Assert.IsNull (client.SslHashAlgorithm, "Expected SslHashAlgorithm to be null after disconnecting"); + Assert.IsNull (client.SslHashStrength, "Expected SslHashStrength to be null after disconnecting"); + Assert.IsNull (client.SslKeyExchangeAlgorithm, "Expected SslKeyExchangeAlgorithm to be null after disconnecting"); + Assert.IsNull (client.SslKeyExchangeStrength, "Expected SslKeyExchangeStrength to be null after disconnecting"); Assert.AreEqual (1, disconnected, "DisconnectedEvent"); } } @@ -1001,6 +1075,8 @@ public void TestConnectYahooSocket () Assert.AreEqual (YahooCipherStrength, client.SslCipherStrength); Assert.AreEqual (YahooHashAlgorithm, client.SslHashAlgorithm); Assert.AreEqual (0, client.SslHashStrength); + Assert.AreEqual (YahooKeyExchangeAlgorithm, client.SslKeyExchangeAlgorithm); + Assert.AreEqual (255, client.SslKeyExchangeStrength); Assert.IsFalse (client.IsAuthenticated, "Expected the client to not be authenticated"); Assert.AreEqual (1, connected, "ConnectedEvent"); @@ -1009,6 +1085,13 @@ public void TestConnectYahooSocket () Assert.IsFalse (client.IsSecure, "Expected IsSecure to be false after disconnecting"); Assert.IsFalse (client.IsEncrypted, "Expected IsEncrypted to be false after disconnecting"); Assert.IsFalse (client.IsSigned, "Expected IsSigned to be false after disconnecting"); + Assert.AreEqual (SslProtocols.None, client.SslProtocol, "Expected SslProtocol to be None after disconnecting"); + Assert.IsNull (client.SslCipherAlgorithm, "Expected SslCipherAlgorithm to be null after disconnecting"); + Assert.IsNull (client.SslCipherStrength, "Expected SslCipherStrength to be null after disconnecting"); + Assert.IsNull (client.SslHashAlgorithm, "Expected SslHashAlgorithm to be null after disconnecting"); + Assert.IsNull (client.SslHashStrength, "Expected SslHashStrength to be null after disconnecting"); + Assert.IsNull (client.SslKeyExchangeAlgorithm, "Expected SslKeyExchangeAlgorithm to be null after disconnecting"); + Assert.IsNull (client.SslKeyExchangeStrength, "Expected SslKeyExchangeStrength to be null after disconnecting"); Assert.AreEqual (1, disconnected, "DisconnectedEvent"); } } @@ -1051,6 +1134,8 @@ public async Task TestConnectYahooSocketAsync () Assert.AreEqual (YahooCipherStrength, client.SslCipherStrength); Assert.AreEqual (YahooHashAlgorithm, client.SslHashAlgorithm); Assert.AreEqual (0, client.SslHashStrength); + Assert.AreEqual (YahooKeyExchangeAlgorithm, client.SslKeyExchangeAlgorithm); + Assert.AreEqual (255, client.SslKeyExchangeStrength); Assert.IsFalse (client.IsAuthenticated, "Expected the client to not be authenticated"); Assert.AreEqual (1, connected, "ConnectedEvent"); @@ -1059,6 +1144,13 @@ public async Task TestConnectYahooSocketAsync () Assert.IsFalse (client.IsSecure, "Expected IsSecure to be false after disconnecting"); Assert.IsFalse (client.IsEncrypted, "Expected IsEncrypted to be false after disconnecting"); Assert.IsFalse (client.IsSigned, "Expected IsSigned to be false after disconnecting"); + Assert.AreEqual (SslProtocols.None, client.SslProtocol, "Expected SslProtocol to be None after disconnecting"); + Assert.IsNull (client.SslCipherAlgorithm, "Expected SslCipherAlgorithm to be null after disconnecting"); + Assert.IsNull (client.SslCipherStrength, "Expected SslCipherStrength to be null after disconnecting"); + Assert.IsNull (client.SslHashAlgorithm, "Expected SslHashAlgorithm to be null after disconnecting"); + Assert.IsNull (client.SslHashStrength, "Expected SslHashStrength to be null after disconnecting"); + Assert.IsNull (client.SslKeyExchangeAlgorithm, "Expected SslKeyExchangeAlgorithm to be null after disconnecting"); + Assert.IsNull (client.SslKeyExchangeStrength, "Expected SslKeyExchangeStrength to be null after disconnecting"); Assert.AreEqual (1, disconnected, "DisconnectedEvent"); } } diff --git a/UnitTests/Security/SslHandshakeExceptionTests.cs b/UnitTests/Security/SslHandshakeExceptionTests.cs index 30c81e5052..d833db6be6 100644 --- a/UnitTests/Security/SslHandshakeExceptionTests.cs +++ b/UnitTests/Security/SslHandshakeExceptionTests.cs @@ -181,6 +181,10 @@ public FakeClient (IProtocolLogger logger) : base (logger) public override int? SslHashStrength => throw new NotImplementedException (); + public override ExchangeAlgorithmType? SslKeyExchangeAlgorithm => throw new NotImplementedException (); + + public override int? SslKeyExchangeStrength => throw new NotImplementedException (); + public override bool IsAuthenticated => throw new NotImplementedException (); public override int Timeout {