net10.0
A libp2p implementation for .NET
Published
Oct 3, 2026
17d ago
Total Downloads
1.8M
1,758,096
Install
dotnet add package Nethermind.Libp2p.Protocols.Tls --version 1.0.2
| Product | Versions |
|---|---|
| .NET |
README
TLS Protocol
This implementation provides full support for the libp2p TLS handshake protocol as specified in the libp2p TLS specification.
Features
Protocol Compliance
- TLS 1.3 Enforcement: Only TLS 1.3 (and higher) is supported per libp2p spec
- Protocol ID:
/tls/1.0.0as defined in the specification - ALPN: Uses "libp2p" application protocol for negotiation
- Peer Authentication: Mutual TLS with libp2p public key extension
Certificate Features
- libp2p Extension: Custom X.509 extension (OID:
1.3.6.1.4.1.53594.1.1) for peer identity - Self-Signed Certificates: Uses ephemeral keys for certificate signing, not host keys
- Key Type Support: Ed25519, Secp256k1, ECDSA, and RSA key types
- Windows Compatibility: Special handling for Windows CNG key requirements
Security Features
- Certificate Validation: Comprehensive validation per libp2p spec:
- Certificate validity period checking
- Self-signed certificate requirement
- Single certificate (no chains allowed)
- libp2p extension presence verification
- Peer ID matching
- Cryptographic signature verification
- Client Authentication: Required mutual authentication
- Signature Verification: Verifies signature over "libp2p-tls-handshake:" prefix + certificate public key
Usage
The TLS protocol is automatically integrated into the libp2p connection stack. It handles:
- Certificate Generation: Creates ephemeral certificates with libp2p identity embedded
- Handshake: Performs TLS 1.3 handshake with ALPN "libp2p" protocol
- Peer Verification: Validates remote peer certificates against expected peer ID
- Secure Channel: Establishes encrypted communication channel
Implementation Details
Certificate Structure
X.509 Certificate:
βββ Subject: SERIALNUMBER=<random-hex>
βββ Issuer: Same as Subject (self-signed)
βββ Public Key: Ephemeral ECDSA key
βββ Extensions:
β βββ libp2p Public Key Extension (1.3.6.1.4.1.53594.1.1):
β βββ SignedKey (ASN.1):
β βββ publicKey: libp2p peer identity public key (protobuf)
β βββ signature: Signature over "libp2p-tls-handshake:" + cert public key
βββ Validity: 1 day before creation to far future
Signature Process
- Export certificate's public key as
SubjectPublicKeyInfo - Concatenate "libp2p-tls-handshake:" prefix with the key info
- Sign the result using the peer's private identity key
- Embed signature in the libp2p extension
Platform Support
- Cross-platform: Works on Linux, macOS, and Windows
- Windows CNG: Special handling for Windows named CNG keys for SslStream compatibility
- Key Generation: Creates persistent named keys on Windows, ephemeral keys elsewhere
Testing
The implementation includes comprehensive test coverage:
- Basic certificate generation and validation
- Network-level TLS handshake testing
- Bidirectional data exchange validation
- libp2p specification compliance tests
- Error condition handling
Run tests with:
dotnet test Libp2p.Protocols.Tls.Tests
References
Changes from Previous Version
No structural changes between v1.0.1 and v1.0.2.
Adoption Assessment
Assess this package against its supported frameworks, license, maintenance signals and dependency graph before making it a project standard.
Compatibility metadata lists 1 target framework; confirm the exact target used by your application.
Related Guides & Workflows
Learn how to evaluate, integrate, or audit this package in your .NET project.