TLS Configuration
Advanced TLS settings
Below you can find some advanced TLS functionality you can enable.
Advanced TLS settings are only available with custom domains
TLS Client Authentication
With TLS Client Authentication you can configure our platform to require clients to include a client certificate signed by a CA of your choosing. If the client doesn’t provide a certificate or the certificate isn’t signed by the correct CA the request will be denied. If the request includes a valid certificate the request will be forwarded to your service and will include information about the TLS configuration.
To configure TLS client authentication you can use the configuration below:
Headers
The following headers will be added to all successful requests:
ssl-client-cert
: The client cetificate that was usedssl-client-issuer-dn
: Client certificate’s issuer DNssl-client-subject-dn
: Client certificate;s distinguished namessl-client-verify
: Result of the operation. As we only forward requests on success the value should always beSUCCESS
.
Guide
Here is a quick guide on how to enable TLS client authentication for the functions service using self-signed certificates.
Creating the CA
First we need to create a CA that will be used to sign and validate the client certificates.
Generate the CA private key
First, we need to create a private key for our Certificate Authority. We’ll use a 4096-bit RSA key for strong security.
This command will prompt you to enter a passphrase to protect the CA private key. Make sure to choose a strong passphrase and keep it safe.
Create the CA certificate
Now that we have the private key, let’s create a self-signed CA certificate:
This command will prompt you for various details to include in the certificate. The most important field is the Common Name (CN), which should be a descriptive name for your CA.
The resulting ca.key
file will be needed later to sign client certificates while the result ca.crt
will be needed to validate them.
Creating client certificates
Now we can proceed to create client certificats. You can repeat the steps below to create as many as you need.
Generate a private key for the client
First, we’ll create a private key for the client certificate:
Create a Certificate Signing Request (CSR) for the client
Now, we’ll create a CSR for the client certificate:
Fill in the prompted information. The Common Name (CN) should typically be the name of the client or user.
Create a configuration file for the client certificate
Create a file named client.ext
with the following content:
This configuration specifies that the certificate is for client authentication.
Generate the client certificate
Now, we’ll use our CA to sign the client certificate:
This command will prompt you for the CA private key passphrase you set earlier.
client.key
and client.crt
files will be needed by the user to authenticate requests.Configure your service
With everything in place you can configure your service. Imagine we have an already deployed project and we want to enable this for all functions. First we will head to the dashboard -> project -> settings -> secrets and create a new secret named CLIENT_CA
with the contents of the ca.crt
file. Afterwards we will deploy the following configuration:
Profit
Our project has a function that echoes back request parameters, including headers. We will use this to inspect the TLS headers added to the request and that you can use for further validation if you need it. First, we can query the function without passing any client certificate:
As you can see the request was rejected. Now we can add a valid client certificate and the corresponding key to the request:
With a valid certificate you can see the request went through and it includes the ssl-client-*
headers providing additional information about it.