AngelHttp.secure constructor
AngelHttp.secure(})
Creates an HTTPS server.
Provide paths to a certificate chain and server key (both .pem). If no password is provided, a random one will be generated upon running the server.
requestClientCertificate and requireClientCertificate are as of
AngelHttp.fromSecurityContext:
give clientAuthoritiesPath, a .pem of the certificates that may sign
a client's, to trust them.
Implementation
factory AngelHttp.secure(
Angel app,
String certificateChainPath,
String serverKeyPath, {
String? password,
bool useZone = true,
bool requestClientCertificate = false,
bool requireClientCertificate = false,
String? clientAuthoritiesPath,
}) {
var certificateChain = Platform.script
.resolve(certificateChainPath)
.toFilePath();
var serverKey = Platform.script.resolve(serverKeyPath).toFilePath();
var serverContext = SecurityContext();
serverContext.useCertificateChain(certificateChain, password: password);
serverContext.usePrivateKey(serverKey, password: password);
if (clientAuthoritiesPath != null) {
var authorities = Platform.script
.resolve(clientAuthoritiesPath)
.toFilePath();
serverContext
..setClientAuthorities(authorities)
..setTrustedCertificates(authorities);
}
return AngelHttp.fromSecurityContext(
app,
serverContext,
useZone: useZone,
requestClientCertificate: requestClientCertificate,
requireClientCertificate: requireClientCertificate,
);
}