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.
class NativeDtlsContext
Types 1
classNativeDtlsContext : DtlsContext
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
NativeTlsTrustStore trustStore_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.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 setAlpnProtocols(const(string)[] protocols) @safe pure nothrowSets the ALPN protocols to offer/accept.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.