DTLS 0.5.1

dotnet add package DTLS --version 0.5.1
                    
NuGet\Install-Package DTLS -Version 0.5.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.5.1" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="DTLS" Version="0.5.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.5.1
                    
#r "nuget: DTLS, 0.5.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.5.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.5.1
                    
Install as a Cake Addin
#tool nuget:?package=DTLS&version=0.5.1
                    
Install as a Cake Tool

DTLS

NuGet

High-performance DTLS (Datagram Transport Layer Security) library for .NET.

Usage

datagrams is an IDatagramTransport for one peer. Use cancellationToken to cancel the operations.

Client

using DTLS.Dtls;
using System.Text;

DtlsClientOptions options = new() { ServerName = "example.com" };

using DtlsTransport client = await DtlsTransport.CreateClientAsync(datagrams, options, cancellationToken);
await client.HandshakeAsync(cancellationToken);

await client.SendAsync("Hello, DTLS!"u8.ToArray(), cancellationToken);

byte[] buffer = new byte[65536];
int length = await client.ReceiveAsync(buffer, cancellationToken);
Console.WriteLine(Encoding.UTF8.GetString(buffer, 0, length));

await client.CloseAsync(cancellationToken);

Server certificates are validated during the handshake. Set RemoteCertificateValidation to customize validation.

Server

using DTLS.Dtls;

DtlsServerOptions options = new() { Certificate = serverCertificate };

using DtlsTransport server = await DtlsTransport.CreateServerAsync(datagrams, options, cancellationToken);
await server.HandshakeAsync(cancellationToken);

byte[] buffer = new byte[65536];
int length = await server.ReceiveAsync(buffer, cancellationToken);
if (length > 0)
{
    await server.SendAsync(buffer.AsMemory(0, length), cancellationToken);
}

await server.CloseAsync(cancellationToken);

serverCertificate must contain an exportable ECDSA private key.

Dispose the underlying transport and supplied certificates yourself.

API

Type Purpose
DtlsTransport Asynchronous handshake, send, receive, and close operations.
DtlsSession Protocol processing when you manage I/O and timers yourself.
IDatagramTransport Transport interface that preserves datagram boundaries.
DtlsClientOptions Server name and optional client certificate.
DtlsServerOptions Server certificate and client authentication.
DtlsVersion Protocol versions for MinVersion and MaxVersion.

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.5.1 0 9/9/2026
0.5.0 148 9/6/2026
0.4.1 1,154 4/26/2026
0.4.0 116 4/25/2026
0.3.4 4,399 3/12/2026
0.3.3 283 3/11/2026
0.3.2 84 3/11/2026
0.3.1 98 3/10/2026
0.3.0 90 3/10/2026
0.2.0 103 3/1/2026
0.1.0 102 2/27/2026