Docsright arrowEdge Stackright arrow1.12right arrowTransport Layer Security (TLS)

10 min • read

Transport Layer Security (TLS)

The Ambassador Edge Stack's robust TLS support exposes configuration options for different TLS use cases including:

Host

As explained in the Host reference, a Host represents a domain in Ambassador and defines how TLS is managed on that domain. In the Ambassador Edge Stack, the simplest configuration of a Host will enable TLS with a self-signed certificate and redirect cleartext traffic to HTTPS.

WARNING - Host Configuration: The requestPolicy property of the Host CRD is applied globally within an Edge Stack instance, even if it is applied to only one Host when multiple Hosts are configured. Different requestPolicy behaviors cannot be applied to different Hosts. It is recommended to apply an identical requestPolicy to all Hosts instead of assuming the behavior, to create a more human readable config.

If a requestPolicy is not defined for a Host, it's assumed to be Redirect, so even if a Host does not specify it, the default requestPolicy of Redirect will be applied to all Hosts in that Edge Stack instance. If the behavior expected out of Edge Stack is anything other than Redirect, it must be explicitly enumerated in all Host resources.

Unexpected behavior can occur when multiple Host resources are not using the same value for requestPolicy.

The insecure-action can be one of:

  • Redirect (the default): redirect to HTTPS
  • Route: go ahead and route as normal; this will allow handling HTTP requests normally
  • Reject: reject the request with a 400 response

The example below does not define a requestPolicy; however, this is something to keep in mind as you begin using the Host CRD in Ambassador.

For more information, please refer to the Host documentation.

Automatic TLS with ACME

With the Ambassador Edge Stack, the Host can be configured to completely manage TLS by requesting a certificate from a Certificate Authority using the ACME HTTP-01 challenge.

After creating a DNS record, configuring the Ambassador Edge Stack to get a certificate from the default CA Let's Encrypt is as simple as providing a hostname and your email for the certificate:

Ambassador will now request a certificate from the CA and store it in a secret in the same namespace as the Host.

Bring your own certificate

For both the Ambassador Edge Stack and API Gateway, the Host can read a certificate from a Kubernetes secret and use that certificate to terminate TLS on a domain.

The following will configure Ambassador to grab a certificate from a secret named host-secret and use that secret for terminating TLS on the host.example.com domain:

Ambassador will now use the certificate in host-secret to terminate TLS.

Host and TLSContext

The Host will configure basic TLS termination settings in Ambassador. If you need more advanced TLS options on a domain, such as setting the minimum TLS version, you can do it in one of the following ways.

Create a TLSContext with the name {{HOST}}-context

You can create a TLSContext with the name {{NAME_OF_HOST}}-context, hosts set to the same hostname, and secret set to the same tlsSecret.

For example, to enforce a minimum TLS version on the Host above, create a TLSContext named example-host-context with the following configuration:

Full reference for all options available to the TLSContext can be found below.

You can create a new TLSContext with the desired configuration and link it to the Host via the tlsContext field.

For example, to enforce a minimum TLS version on the Host above, create a TLSContext with any name with the following configuration:

and link it to the Host via the tlsContext field as shown:

Note: Any hosts or secret in the TLSContext must be the compatible with the Host to which it is being linked.

Specify TLS configuration in the Host

You can specify TLS configuration directly in the Host via the tls field.

For example, to enforce a minimum TLS version on the Host, the configuration will look like this:

The following fields are accepted in the tls field:

See TLSContext below to read more on the description of these fields.

TLSContext

The TLSContext is used to configure advanced TLS options in Ambassador. Remember, a TLSContext should always be paired with a Host.

A full schema of the TLSContext can be found below with descriptions of the different configuration options.

alpn_protocols

The alpn_protocols setting configures the TLS ALPN protocol. To use gRPC over TLS, set alpn_protocols: h2. If you need to support HTTP/2 upgrade from HTTP/1, set alpn_protocols: h2,http/1.1 in the configuration.

HTTP/2 Support

The alpn_protocols setting is also required for HTTP/2 support.

Without setting alpn_protocols as shown above, HTTP2 will not be available via negotiation and will have to be explicitly requested by the client.

If you leave off http/1.1, only HTTP2 connections will be supported.

TLS Parameters

The min_tls_version setting configures the minimum TLS protocol version that Ambassador Edge Stack will use to establish a secure connection. When a client using a lower version attempts to connect to the server, the handshake will result in the following error: tls: protocol version not supported.

The max_tls_version setting configures the maximum TLS protocol version that Ambassador Edge Stack will use to establish a secure connection. When a client using a higher version attempts to connect to the server, the handshake will result in the following error: tls: server selected unsupported protocol version.

The cipher_suites setting configures the supported ciphers found below using the configuration parameters for BoringSSL when negotiating a TLS 1.0-1.2 connection. This setting has no effect when negotiating a TLS 1.3 connection. When a client does not support a matching cipher a handshake error will result.

The ecdh_curves setting configures the supported ECDH curves when negotiating a TLS connection. When a client does not support a matching ECDH a handshake error will result.

TLS Module (Deprecated)

The TLS Module is deprecated. TLSContext should be used when using Ambassador version 0.50.0 and above.

For users of the Ambassador Edge Stack, see the Host CRD reference for more information.