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
private NativeTlsTrustStore trustStore_private TlsVerifyMode verifyMode_private DtlsVerifyCallback verifyCallback_private DtlsVersion minVersion_private DtlsVersion maxVersion_private string[] alpnProtocols_private string certChainPem_private const(ubyte)[][] certChainDer_private string privateKeyPem_private string privateKeyPassword_private ubyte[] privateKeyDer_private bool cidEnabled_private ubyte cidLength_private bool sessionResumption_private size_t maxEarlyData_private 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.void setSrtpProfiles(const(SrtpProfile[]) profiles) @safe pure nothrowSets the DTLS-SRTP profiles to negotiate (RFC 5764).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.