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.
Each path is of a file, as resolveFilePath reads it: an absolute one,
as C:\certs\server.pem on Windows, as it is, and a relative one of the
directory of the script.
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 = resolveFilePath(certificateChainPath);
var serverKey = resolveFilePath(serverKeyPath);
var serverContext = SecurityContext();
serverContext.useCertificateChain(certificateChain, password: password);
serverContext.usePrivateKey(serverKey, password: password);
if (clientAuthoritiesPath != null) {
var authorities = resolveFilePath(clientAuthoritiesPath);
serverContext
..setClientAuthorities(authorities)
..setTrustedCertificates(authorities);
}
return AngelHttp.fromSecurityContext(
app,
serverContext,
useZone: useZone,
requestClientCertificate: requestClientCertificate,
requireClientCertificate: requireClientCertificate,
);
}