DTLS 0.4.1

dotnet add package DTLS --version 0.4.1
                    
NuGet\Install-Package DTLS -Version 0.4.1
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="DTLS" Version="0.4.1" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="DTLS" Version="0.4.1" />
                    
Directory.Packages.props
<PackageReference Include="DTLS" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add DTLS --version 0.4.1
                    
#r "nuget: DTLS, 0.4.1"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package DTLS@0.4.1
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=DTLS&version=0.4.1
                    
Install as a Cake Addin
#tool nuget:?package=DTLS&version=0.4.1
                    
Install as a Cake Tool

DTLS

NuGet

High-performance DTLS (Datagram Transport Layer Security) library for .NET, powered by a native Rust backend.

  • Sans-I/O design for maximum flexibility
  • AOT compatible
  • DTLS 1.2 / 1.3 support

Usage

Client

DtlsClientOptions options = new()
{
    ServerName = "example.com",
    RemoteCertificateValidation = (cert, chain, errors) => true,
};

await using DtlsTransport transport = await DtlsTransport.CreateClientAsync(udpTransport, options);
await transport.HandshakeAsync();

await transport.SendAsync(data);
int bytesRead = await transport.ReceiveAsync(buffer);

await transport.CloseAsync();

Server

DtlsServerOptions options = new()
{
    Certificate = serverCert,
};

await using DtlsTransport transport = await DtlsTransport.CreateServerAsync(udpTransport, options);
await transport.HandshakeAsync();

int bytesRead = await transport.ReceiveAsync(buffer);
await transport.SendAsync(response);

API

IDatagramTransport

Low-level datagram transport abstraction that preserves message boundaries.

public interface IDatagramTransport
{
    ValueTask<int> ReceiveAsync(Memory<byte> buffer, CancellationToken cancellationToken = default);
    ValueTask SendAsync(ReadOnlyMemory<byte> datagram, CancellationToken cancellationToken = default);
}

DtlsTransport

Async I/O wrapper that bridges the sans-I/O protocol engine with an IDatagramTransport.

Method Description
CreateClientAsync Create a DTLS client
CreateServerAsync Create a DTLS server
HandshakeAsync Perform DTLS handshake
SendAsync Send encrypted datagram
ReceiveAsync Receive decrypted datagram
CloseAsync Send close_notify for graceful shutdown

DtlsSession

Sans-I/O DTLS protocol engine for advanced scenarios.

Method Description
CreateClient Create a client session
CreateServer Create a server session
Feed Feed received data into the engine
HandleTimeout Handle retransmission timeout
Send Encrypt plaintext into output
TryReceive Try to read decrypted application data
Close Queue close_notify for graceful shutdown
VerifyPeer Verify peer certificate

Options

DtlsClientOptions — Client configuration:

Property Description
ServerName Required. Server hostname for SNI
ClientCertificate Optional client certificate
RemoteCertificateValidation Custom certificate validation callback
HandshakeTimeout Handshake timeout (default 15s)
Version SSL/TLS protocol version

DtlsServerOptions — Server configuration:

Property Description
Certificate Required. Server certificate with private key
RemoteCertificateValidation Custom certificate validation callback
HandshakeTimeout Handshake timeout (default 15s)
Version SSL/TLS protocol version
RequireClientCertificate Whether to require client certificate

License

MIT

Product Compatible and additional computed target framework versions.
.NET net10.0 is compatible.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • net10.0

    • No dependencies.

NuGet packages (1)

Showing the top 1 NuGet packages that depend on DTLS:

Package Downloads
Stun.Net

Package Description

GitHub repositories (1)

Showing the top 1 popular GitHub repositories that depend on DTLS:

Repository Stars
HMBSbige/NatTypeTester
测试当前网络的 NAT 类型(STUN)
Version Downloads Last Updated
0.4.1 210 4/26/2026
0.4.0 90 4/25/2026
0.3.4 1,554 3/12/2026
0.3.3 247 3/11/2026
0.3.2 64 3/11/2026
0.3.1 61 3/10/2026
0.3.0 66 3/10/2026
0.2.0 74 3/1/2026
0.1.0 70 2/27/2026