From 82e8469c1b6cbd4e32bc549407b5273859aaa8b0 Mon Sep 17 00:00:00 2001 From: ladeak Date: Sun, 21 Jun 2026 16:31:29 +0200 Subject: [PATCH 1/2] Adding Obsolete attribute on the properties of ITlsHandshakeFeature. --- src/CHttpServer/CHttpServer/HttpsConnectionMiddleware.cs | 8 +++++++- tests/CHttpServer.Tests/TestBase.cs | 3 +++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/src/CHttpServer/CHttpServer/HttpsConnectionMiddleware.cs b/src/CHttpServer/CHttpServer/HttpsConnectionMiddleware.cs index 928f4ac..46777e8 100644 --- a/src/CHttpServer/CHttpServer/HttpsConnectionMiddleware.cs +++ b/src/CHttpServer/CHttpServer/HttpsConnectionMiddleware.cs @@ -252,17 +252,23 @@ public X509Certificate2? ClientCertificate // Required for TLS Handshake feature public TlsCipherSuite? NegotiatedCipherSuite => _sslStream.NegotiatedCipherSuite; - + + [Obsolete("Obsolete by BCL, use NegotiatedCipherSuite instead.")] public CipherAlgorithmType CipherAlgorithm => _sslStream.CipherAlgorithm; + [Obsolete("Obsolete by BCL, use NegotiatedCipherSuite instead.")] public int CipherStrength => _sslStream.CipherStrength; + [Obsolete("Obsolete by BCL, use NegotiatedCipherSuite instead.")] public HashAlgorithmType HashAlgorithm => _sslStream.HashAlgorithm; + [Obsolete("Obsolete by BCL, use NegotiatedCipherSuite instead.")] public int HashStrength => _sslStream.HashStrength; + [Obsolete("Obsolete by BCL, use NegotiatedCipherSuite instead.")] public ExchangeAlgorithmType KeyExchangeAlgorithm => _sslStream.KeyExchangeAlgorithm; + [Obsolete("Obsolete by BCL, use NegotiatedCipherSuite instead.")] public int KeyExchangeStrength => _sslStream.KeyExchangeStrength; public Task GetClientCertificateAsync(CancellationToken cancellationToken) diff --git a/tests/CHttpServer.Tests/TestBase.cs b/tests/CHttpServer.Tests/TestBase.cs index e205e75..7d3713c 100644 --- a/tests/CHttpServer.Tests/TestBase.cs +++ b/tests/CHttpServer.Tests/TestBase.cs @@ -116,14 +116,17 @@ internal class TestTls : ITlsHandshakeFeature { public SslProtocols Protocol => SslProtocols.Tls12; + [Obsolete("Obsolete by BCL, use NegotiatedCipherSuite instead.")] public CipherAlgorithmType CipherAlgorithm => throw new NotImplementedException(); public int CipherStrength => throw new NotImplementedException(); + [Obsolete("Obsolete by BCL, use NegotiatedCipherSuite instead.")] public HashAlgorithmType HashAlgorithm => throw new NotImplementedException(); public int HashStrength => throw new NotImplementedException(); + [Obsolete("Obsolete by BCL, use NegotiatedCipherSuite instead.")] public ExchangeAlgorithmType KeyExchangeAlgorithm => throw new NotImplementedException(); public int KeyExchangeStrength => throw new NotImplementedException(); From 2315d2f611a88c2e6c27f5dd47f8b3a088700bd3 Mon Sep 17 00:00:00 2001 From: ladeak Date: Sun, 21 Jun 2026 16:41:04 +0200 Subject: [PATCH 2/2] Addressing some warnings --- src/CHttpServer/CHttpServer/DuplexPipeStreamAdapter.cs | 2 +- src/CHttpServer/CHttpServer/Http3/Http3FramingStreamWriter.cs | 2 +- src/CHttpServer/CHttpServer/HttpsConnectionMiddleware.cs | 2 +- src/CHttpServer/TestCHttpServerApplication/Program.cs | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/CHttpServer/CHttpServer/DuplexPipeStreamAdapter.cs b/src/CHttpServer/CHttpServer/DuplexPipeStreamAdapter.cs index ee44f5f..6b062cb 100644 --- a/src/CHttpServer/CHttpServer/DuplexPipeStreamAdapter.cs +++ b/src/CHttpServer/CHttpServer/DuplexPipeStreamAdapter.cs @@ -7,7 +7,7 @@ namespace CHttpServer; internal class DuplexPipeStreamAdapter : Stream, IDuplexPipe where TStream : Stream { private bool _disposed; - private readonly object _disposeLock = new object(); + private readonly Lock _disposeLock = new(); public DuplexPipeStreamAdapter(TStream stream, StreamPipeReaderOptions readerOptions, StreamPipeWriterOptions writerOptions) { diff --git a/src/CHttpServer/CHttpServer/Http3/Http3FramingStreamWriter.cs b/src/CHttpServer/CHttpServer/Http3/Http3FramingStreamWriter.cs index 18c0ec6..bae9dc8 100644 --- a/src/CHttpServer/CHttpServer/Http3/Http3FramingStreamWriter.cs +++ b/src/CHttpServer/CHttpServer/Http3/Http3FramingStreamWriter.cs @@ -154,7 +154,7 @@ public override async ValueTask WriteAsync(ReadOnlyMemory sou _responseStream.Flush(); return new FlushResult(isCanceled: false, isCompleted: false); } - catch (Exception ex) + catch (Exception) { _isCompleted = true; ClearSegments(CollectionsMarshal.AsSpan(_segments)); diff --git a/src/CHttpServer/CHttpServer/HttpsConnectionMiddleware.cs b/src/CHttpServer/CHttpServer/HttpsConnectionMiddleware.cs index 46777e8..71a4fc8 100644 --- a/src/CHttpServer/CHttpServer/HttpsConnectionMiddleware.cs +++ b/src/CHttpServer/CHttpServer/HttpsConnectionMiddleware.cs @@ -54,7 +54,7 @@ public async Task OnConnectionAsync(CHttp2ConnectionContext context) } var sslDuplexPipe = CreateSslDuplexPipe( - context.Transport, + context.Transport!, context.Features.Get()?.MemoryPool ?? MemoryPool.Shared); var sslStream = sslDuplexPipe.Stream; diff --git a/src/CHttpServer/TestCHttpServerApplication/Program.cs b/src/CHttpServer/TestCHttpServerApplication/Program.cs index 3ea9cc9..8e3983a 100644 --- a/src/CHttpServer/TestCHttpServerApplication/Program.cs +++ b/src/CHttpServer/TestCHttpServerApplication/Program.cs @@ -58,7 +58,7 @@ public class Data { - public string Message { get; set; } + public required string Message { get; set; } } [JsonSerializable(typeof(Data))]