DtlsClientContext constructor
DtlsClientContext({})
verify
enables certificate verification (recommended).
To allow the verification to succeed, system certificates have to be
imported using withTrustedRoots
, or custom root certificates
in DER format need to be imported with rootCertificates
.
System certificates are available only when OpenSSL is installed by
the system.
ciphers
controls the cipher suites offered to the server.
Implementation
DtlsClientContext({
bool verify = true,
bool withTrustedRoots = false,
List<Uint8List> rootCertificates = const [],
String? ciphers,
}) {
if (withTrustedRoots) {
lib.SSL_CTX_set_default_verify_paths(_ctx);
}
_addRoots(rootCertificates);
lib.SSL_CTX_set_verify(
_ctx, verify ? SSL_VERIFY_PEER : SSL_VERIFY_NONE, nullptr);
if (ciphers != null) {
final ciphersStr = ciphers.toNativeUtf8();
lib.SSL_CTX_set_cipher_list(_ctx, ciphersStr.cast());
malloc.free(ciphersStr);
}
}