Class TlsConfig

java.lang.Object
io.floci.testcontainers.config.TlsConfig

public class TlsConfig extends Object
Optional TLS configuration for enabling HTTPS on the Floci server. When enabled, all endpoints are reachable via https:// and WebSocket connections work via wss://.

Both HTTP and HTTPS are served simultaneously (LocalStack parity).

Instances are created via TlsConfig.Builder:


 TlsConfig config = TlsConfig.builder()
     .enabled(true)
     .selfSigned(true)
     .build();
 
  • Method Details

    • builder

      public static TlsConfig.Builder builder()
      Returns a new TlsConfig.Builder for this configuration.
      Returns:
      a new builder
    • toBuilder

      public TlsConfig.Builder toBuilder()
      Returns a new TlsConfig.Builder for this configuration, initialized with the current values of this instance.
      Returns:
      a new builder pre-populated with this configuration's values
    • isEnabled

      public boolean isEnabled()
      Returns whether TLS/HTTPS is enabled on the server.
      Returns:
      true if TLS is enabled
    • getCertPath

      public Optional<String> getCertPath()
      Returns the path to the PEM certificate file, or empty if not set.
      Returns:
      the certificate path, or empty
    • getKeyPath

      public Optional<String> getKeyPath()
      Returns the path to the PEM private key file, or empty if not set.
      Returns:
      the private key path, or empty
    • isSelfSigned

      public boolean isSelfSigned()
      Returns whether a self-signed certificate should be auto-generated when no certPath/keyPath is provided.
      Returns:
      true if self-signed certificate generation is enabled
    • getAwsHttpsPort

      public int getAwsHttpsPort()
      Returns the additional port the TLS proxy binds for AWS-style HTTPS traffic, alongside the public Floci port.

      CDK/CloudFormation custom resources send their cfn-response callback with bundled code that hardcodes https:// and ignores the port in the ResponseURL, so the PUT lands on the conventional 443 regardless of Floci's configured port. Binding 443 here (with the same HTTP/HTTPS protocol detection used on the main port) lets those callbacks — and any other client that assumes AWS lives on 443 — reach Floci.

      Default 443. Set to 0 to disable the extra binding (e.g. when Floci runs unprivileged or another process owns 443). When equal to the main Floci port only a single listener is started.

      Returns:
      the additional AWS-style HTTPS port
    • applyEnvVarsToContainer

      public void applyEnvVarsToContainer(org.testcontainers.containers.Container<?> container)
      Applies this TLS configuration to the given container by setting the appropriate environment variables.
      Parameters:
      container - the container to configure