diff --git a/Examples/SampleApp/Examples/CustomEndpointListenerExample.cs b/Examples/SampleApp/Examples/CustomEndpointListenerExample.cs index 62ae255..001c356 100644 --- a/Examples/SampleApp/Examples/CustomEndpointListenerExample.cs +++ b/Examples/SampleApp/Examples/CustomEndpointListenerExample.cs @@ -1,6 +1,7 @@ using System; using System.IO; using System.IO.Pipelines; +using System.Net.Security; using System.Security.Authentication; using System.Security.Cryptography.X509Certificates; using System.Threading; @@ -95,6 +96,9 @@ public void Dispose() public PipeWriter Output => _securableDuplexPipe.Output; public bool IsSecure => _securableDuplexPipe.IsSecure; + + /// + public SslProtocols SslProtocol => (_securableDuplexPipe as SslStream)?.SslProtocol ?? SslProtocols.None; } public sealed class LoggingPipeReader : PipeReader diff --git a/Src/SmtpServer/IO/ISecurableDuplexPipe.cs b/Src/SmtpServer/IO/ISecurableDuplexPipe.cs index ffa5047..d937518 100644 --- a/Src/SmtpServer/IO/ISecurableDuplexPipe.cs +++ b/Src/SmtpServer/IO/ISecurableDuplexPipe.cs @@ -25,5 +25,10 @@ public interface ISecurableDuplexPipe : IDuplexPipe, IDisposable /// Returns a value indicating whether or not the current pipeline is secure. /// bool IsSecure { get; } + + /// + /// Returns the used SslProtocol of a secure pipeline + /// + SslProtocols SslProtocol { get; } } } diff --git a/Src/SmtpServer/IO/SecurableDuplexPipe.cs b/Src/SmtpServer/IO/SecurableDuplexPipe.cs index 70ede62..cc6a278 100644 --- a/Src/SmtpServer/IO/SecurableDuplexPipe.cs +++ b/Src/SmtpServer/IO/SecurableDuplexPipe.cs @@ -29,13 +29,7 @@ internal SecurableDuplexPipe(Stream stream, Action disposeAction) Output = PipeWriter.Create(_stream); } - /// - /// Upgrade to a secure pipeline. - /// - /// The X509Certificate used to authenticate the server. - /// The value that represents the protocol used for authentication. - /// The cancellation token. - /// A task that asynchronously performs the operation. + /// public async Task UpgradeAsync(X509Certificate certificate, SslProtocols protocols, CancellationToken cancellationToken = default) { var sslStream = new SslStream(_stream, true); @@ -100,14 +94,10 @@ public void Dispose() /// public PipeWriter Output { get; private set; } - /// - /// 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; } }