TlsConfig constructor
TlsConfig({
- String? certFilePath,
- String? keyFilePath,
- String? trustedCertificatesPath,
- SecurityContext? securityContext,
- bool requireClientCert = false,
Creates a TLS configuration.
Either securityContext or both certFilePath and keyFilePath
must be provided. Throws ArgumentError if neither is set.
If requireClientCert is true, either trustedCertificatesPath
or securityContext must be provided.
Implementation
TlsConfig({
this.certFilePath,
this.keyFilePath,
this.trustedCertificatesPath,
this.securityContext,
this.requireClientCert = false,
}) {
if (securityContext == null) {
if (certFilePath == null || keyFilePath == null) {
throw ArgumentError(
'Either securityContext or both certFilePath and keyFilePath must be provided',
);
}
}
if (requireClientCert &&
securityContext == null &&
trustedCertificatesPath == null) {
throw ArgumentError(
'requireClientCert requires trustedCertificatesPath or a pre-built securityContext',
);
}
}