ddn.net.dtls.context

Native DTLS context implementation.

Holds DTLS configuration (certificates, keys, protocol versions, verification settings) and creates DtlsEngine instances for client and server connections.

Contexts are created once via createDtlsContext() and reused for many DTLS engines.

Types 1

Pure D DTLS context backed by ddn-crypto primitives.

Stores shared configuration that is applied to every engine created by clientEngine() or serverEngine().

Example:

auto ctx = createDtlsContext();
ctx.trustStore.loadSystemCerts();
ctx.setCertificateChain(pemData);
ctx.setPrivateKey(pemKey);
auto engine = ctx.serverEngine(transport, timer);

Fields
TlsVerifyMode verifyMode_
DtlsVerifyCallback verifyCallback_
DtlsVersion minVersion_
DtlsVersion maxVersion_
string[] alpnProtocols_
string certChainPem_
const(ubyte)[][] certChainDer_
string privateKeyPem_
string privateKeyPassword_
ubyte[] privateKeyDer_
bool cidEnabled_
ubyte cidLength_
bool sessionResumption_
size_t maxEarlyData_
SrtpProfile[] srtpProfiles_
Methods
void setCertificateChain(const(char)[] pemData)Sets the certificate chain from PEM-encoded data.
void setCertificateChainDer(const(ubyte[])[] derCertificates)Sets the certificate chain from DER-encoded certificates.
void setPrivateKey(const(char)[] pemData, const(char)[] password = null)Sets the private key from PEM-encoded data.
void setPrivateKeyDer(const(ubyte)[] derData, const(char)[] password = null)Sets the private key from DER-encoded data.
TlsTrustStore trustStore() @propertyReturns: The trust store for adding trusted CA certificates.
void setVerifyMode(TlsVerifyMode mode) @safe pure nothrow @nogcSets the certificate verification mode.
void setVerifyCallback(DtlsVerifyCallback callback) @safe pure nothrowSets a custom certificate verification callback.
void setMinVersion(DtlsVersion ver) @safe pure nothrow @nogcSets the minimum DTLS version.
void setMaxVersion(DtlsVersion ver) @safe pure nothrow @nogcSets the maximum DTLS version.
void setAlpnProtocols(const(string)[] protocols) @safe pure nothrowSets the ALPN protocols to offer/accept.
void setConnectionId(bool enable, ubyte cidLength = 8) @safe pure nothrow @nogc
void setSessionResumption(bool enable, size_t maxEarlyData = 16384) @safe pure nothrow @nogc
void setSrtpProfiles(const(SrtpProfile[]) profiles) @safe pure nothrow
DtlsEngine clientEngine(DtlsTransport transport, DtlsTimerSink timer, string serverName)Creates a DTLS client engine with this context's configuration.
DtlsEngine serverEngine(DtlsTransport transport, DtlsTimerSink timer)Creates a DTLS server engine with this context's configuration.
private void applyConfig(NativeDtlsEngine engine)Apply stored configuration to a newly created engine.
Constructors
this()Constructs a NativeDtlsContext with secure defaults.