Skip to content

Commit ed310ba

Browse files
authored
Fix interface inconsistency SecurableDuplexPipe (cosullivan#240)
* Fix interface inconsistency SecurableDuplexPipe * Update CustomEndpointListenerExample.cs
1 parent ba859f6 commit ed310ba

File tree

3 files changed

+12
-13
lines changed

3 files changed

+12
-13
lines changed

Examples/SampleApp/Examples/CustomEndpointListenerExample.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
using System;
22
using System.IO;
33
using System.IO.Pipelines;
4+
using System.Net.Security;
45
using System.Security.Authentication;
56
using System.Security.Cryptography.X509Certificates;
67
using System.Threading;
@@ -95,6 +96,9 @@ public void Dispose()
9596
public PipeWriter Output => _securableDuplexPipe.Output;
9697

9798
public bool IsSecure => _securableDuplexPipe.IsSecure;
99+
100+
/// <inheritdoc />
101+
public SslProtocols SslProtocol => (_securableDuplexPipe as SslStream)?.SslProtocol ?? SslProtocols.None;
98102
}
99103

100104
public sealed class LoggingPipeReader : PipeReader

Src/SmtpServer/IO/ISecurableDuplexPipe.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,5 +25,10 @@ public interface ISecurableDuplexPipe : IDuplexPipe, IDisposable
2525
/// Returns a value indicating whether or not the current pipeline is secure.
2626
/// </summary>
2727
bool IsSecure { get; }
28+
29+
/// <summary>
30+
/// Returns the used SslProtocol of a secure pipeline
31+
/// </summary>
32+
SslProtocols SslProtocol { get; }
2833
}
2934
}

Src/SmtpServer/IO/SecurableDuplexPipe.cs

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -29,13 +29,7 @@ internal SecurableDuplexPipe(Stream stream, Action disposeAction)
2929
Output = PipeWriter.Create(_stream);
3030
}
3131

32-
/// <summary>
33-
/// Upgrade to a secure pipeline.
34-
/// </summary>
35-
/// <param name="certificate">The X509Certificate used to authenticate the server.</param>
36-
/// <param name="protocols">The value that represents the protocol used for authentication.</param>
37-
/// <param name="cancellationToken">The cancellation token.</param>
38-
/// <returns>A task that asynchronously performs the operation.</returns>
32+
/// <inheritdoc />
3933
public async Task UpgradeAsync(X509Certificate certificate, SslProtocols protocols, CancellationToken cancellationToken = default)
4034
{
4135
var sslStream = new SslStream(_stream, true);
@@ -100,14 +94,10 @@ public void Dispose()
10094
/// </summary>
10195
public PipeWriter Output { get; private set; }
10296

103-
/// <summary>
104-
/// Returns a value indicating whether or not the current pipeline is secure.
105-
/// </summary>
97+
/// <inheritdoc />
10698
public bool IsSecure => _stream is SslStream;
10799

108-
/// <summary>
109-
/// Returns the used SslProtocol of a secure pipeline
110-
/// </summary>
100+
/// <inheritdoc />
111101
public SslProtocols SslProtocol => (_stream as SslStream)?.SslProtocol ?? SslProtocols.None;
112102
}
113103
}

0 commit comments

Comments
 (0)