Skip to content

Latest commit

 

History

188 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

StreamExtended

Actively maintained .NET library for peeking TLS ClientHello / ServerHello (SNI, ALPN, and other extensions) from a stream before SslStream.AuthenticateAsServer / AuthenticateAsClient.

Works on Windows, Linux, and macOS (.NET 10).

Build NuGet NuGet downloads

API docs · Wiki

Features

  • Peek TLS ClientHello and ServerHello without consuming the handshake
  • Read SNI, ALPN, and other hello extensions before choosing a certificate
  • CustomBufferedStream implements IPeekStream so peeked bytes stay available for SslStream

Code Quality

Quality Gate Coverage Lines of Code Bugs Vulnerabilities Code Smells Security Rating Reliability Rating Maintainability Rating Duplicated Lines Technical Debt

Install

dotnet add package StreamExtended

Current line: 2.0 (requires .NET 10). For net45 / netstandard1.3, stay on the 1.0.x packages.

Usage

using StreamExtended;
using StreamExtended.BufferPool;
using StreamExtended.Network;

IBufferPool bufferPool = new DefaultBufferPool();
await using var stream = new CustomBufferedStream(networkStream, bufferPool, bufferSize: 4096, leaveOpen: true);

var clientHello = await SslTools.PeekClientHello(stream, bufferPool);
if (clientHello?.Extensions != null &&
    clientHello.Extensions.TryGetValue("server_name", out var sni))
{
    var hostName = sni.Data;
    // select certificate / continue with SslStream on the same stream
}

var serverHello = await SslTools.PeekServerHello(stream, bufferPool);

CustomBufferedStream implements IPeekStream, so peeked bytes remain available for the subsequent TLS handshake.

Supported platforms

  • Windows, Linux, macOS
  • .NET 10 (net10.0)

API docs

Generated with DocFX on develop: justcoding121.github.io/stream-extended

How-to pages: GitHub Wiki.

Build

dotnet test src/StreamExtended.sln -c Release
dotnet test tests/StreamExtended.Tests/StreamExtended.Tests.csproj -c Release
dotnet test tests/StreamExtended.Integration.Tests/StreamExtended.Integration.Tests.csproj -c Release --filter TestCategory=Integration
dotnet test tests/StreamExtended.Integration.Tests/StreamExtended.Integration.Tests.csproj -c Release --filter TestCategory=E2E
dotnet pack src/StreamExtended/StreamExtended.csproj -c Release

CI runs unit, integration, and e2e on Windows (build) plus Linux and macOS (test matrix). See Building and testing.

License

MIT — see LICENSE.

About

An extended SslStream with support to peek TLS handshake extensions

Topics

Resources

Security policy

Stars

27 stars

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages