From 9d253c479e0f402d6cf2a002fb5815fad0b87a3a Mon Sep 17 00:00:00 2001 From: Tino Hager Date: Tue, 20 Aug 2024 16:12:07 +0200 Subject: [PATCH] Add SslProtocol Info to SecurableDuplexPipe (#222) * Add SslProtocol Info to SecurableDuplexPipe Add the option of querying which SslProtocol was used to establish the connection is added for an encrypted connection * set SslProtocols default to SslProtocols.None --- Src/SmtpServer/IO/SecurableDuplexPipe.cs | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/Src/SmtpServer/IO/SecurableDuplexPipe.cs b/Src/SmtpServer/IO/SecurableDuplexPipe.cs index 32f2c5b..f2207a4 100644 --- a/Src/SmtpServer/IO/SecurableDuplexPipe.cs +++ b/Src/SmtpServer/IO/SecurableDuplexPipe.cs @@ -43,7 +43,7 @@ public async Task UpgradeAsync(X509Certificate certificate, SslProtocols protoco await stream.AuthenticateAsServerAsync(certificate, false, protocols, true).ConfigureAwait(false); _stream = stream; - + Input = PipeReader.Create(_stream); Output = PipeWriter.Create(_stream); } @@ -88,5 +88,10 @@ public void Dispose() /// Returns a value indicating whether or not the current pipeline is secure. /// public bool IsSecure => _stream is SslStream; + + /// + /// Returns the used SslProtocol of a secure pipeline + /// + public SslProtocols SslProtocol => (_stream as SslStream)?.SslProtocol ?? SslProtocols.None; } -} \ No newline at end of file +}