securityContext property Null safety

SecurityContext? securityContext

The context used for setting up HTTPS in an application.

If this value is non-null, the server receiving HTTP requests will only accept requests over HTTPS.

By default, this value is null. If the ApplicationOptions provided to the application are configured to reference a private key and certificate file, this value is derived from that information. You may override this method to provide an alternative means to creating a SecurityContext.

Implementation

SecurityContext? get securityContext {
  if (options!.certificateFilePath == null ||
      options!.privateKeyFilePath == null) {
    return null;
  }

  return SecurityContext()
    ..useCertificateChain(options!.certificateFilePath!)
    ..usePrivateKey(options!.privateKeyFilePath!);
}