AngelHttp2 constructor

AngelHttp2(
  1. Angel app,
  2. SecurityContext securityContext, {
  3. bool useZone = true,
  4. bool allowHttp1 = false,
  5. ServerSettings? settings,
  6. Duration sessionTimeout = const Duration(minutes: 20),
  7. bool requestClientCertificate = false,
  8. bool requireClientCertificate = false,
})

An HTTP/2 server of securityContext.

If requestClientCertificate, the server asks each client for a certificate (mutual TLS), which RequestContext.clientCertificate gives, for HTTP/2 requests and the HTTP/1 ones of allowHttp1 alike. A client may still connect without one. Trust the certificates that may sign one with SecurityContext.setClientAuthorities and SecurityContext.setTrustedCertificates: a client whose certificate does not verify fails the handshake.

If requireClientCertificate, the server asks for one too, and a client that presents none fails the handshake.

Implementation

factory AngelHttp2(
  Angel app,
  SecurityContext securityContext, {
  bool useZone = true,
  bool allowHttp1 = false,
  ServerSettings? settings,
  Duration sessionTimeout = const Duration(minutes: 20),
  bool requestClientCertificate = false,
  bool requireClientCertificate = false,
}) {
  return AngelHttp2.custom(
    app,
    securityContext,
    (address, port, ctx) => SecureServerSocket.bind(
      address,
      port,
      ctx,
      requestClientCertificate: requestClientCertificate,
      requireClientCertificate: requireClientCertificate,
    ),
    useZone: useZone,
    allowHttp1: allowHttp1,
    settings: settings,
    sessionTimeout: sessionTimeout,
  );
}