Configure mTLS on a domain
Upload a Trusted CA certificate, turn on mTLS on a domain, and test the handshake, in Azion Console or with the API.
You can turn on mutual TLS (mTLS) on a domain in Azion Console or with the API. To serve HTTPS on your domain with a server certificate of your own instead, refer to Upload a digital certificate.
With mTLS on, the domain asks each client for a certificate during the TLS handshake. It checks that certificate against a Trusted CA certificate: the certificate of the certificate authority (CA) that signs your clients’ certificates. The setup takes two objects: the Trusted CA certificate and the mTLS fields of the domain. A domain takes no certificate revocation list.
Prerequisites
Console
- A domain whose application is served over HTTPS. The client certificate travels in the TLS handshake, so mTLS checks HTTPS connections only.
- The certificate of your CA, in PEM format. A third-party CA issues it. A certificate that Azion generates cannot serve as the Trusted CA.
- A client certificate that CA signed, with its private key, to test the domain.
- Access to Azion Console. For more information, refer to How to access Azion Console.
Upload the Trusted CA certificate
Certificate Manager stores the Trusted CA certificate with the type trusted_ca_certificate and no private key. The file must be in PEM format, with its -----BEGIN CERTIFICATE----- and -----END CERTIFICATE----- lines, and Certificate Manager refuses any other format. When your chain has intermediate certificates, include them in the same file.
Console
Azion Console uploads the Trusted CA certificate from the form that names it. The Trusted CA Certificate field closes with Create Digital Trusted CA certificate, which takes the PEM file without leaving the form. Turn on mTLS on the domain carries the steps.
Turn on mTLS on the domain
The mTLS fields of the domain turn the check on and name the Trusted CA certificate and the verification mode. Pick the mode:
enforce: the domain ends the handshake when a client presents no certificate, or a certificate the Trusted CA did not sign.permissive: every client completes the handshake, and a firewall rule decides which requests to refuse.
Console
To turn on mTLS on a domain in Azion Console:
Access Azion Console > Domains, and select the domain.
In the Mutual Authentication Settings section, turn on Mutual Authentication.
In Mode, select Enforce or Permissive.
In Trusted CA Certificate, select the certificate of your CA. The field is required, and Create Digital Trusted CA certificate, at the end of the list, uploads one without leaving the form.
Select Save.
The new mode takes several minutes to reach all of Azion’s distributed infrastructure. Until then, some requests still meet the previous configuration, so repeat a test before you trust its result.
Test the handshake
Two requests to the domain show whether it checks clients: one without a client certificate, and one with a certificate the Trusted CA signed. Send them after the mTLS change propagates.
To send a request with no client certificate, run curl in verbose mode:
In enforce mode, the domain requests a certificate, the client sends none, and the handshake fails. curl exits with code 56. With curl built on LibreSSL, the verbose output ends like this:
To send a request with the client certificate, pass the certificate and its private key, here client.pem and client.key:
The handshake completes, and curl prints the status code your application returns:
In permissive mode, both requests complete the handshake and reach the application, and so does a request with a certificate another CA signed.
Deny requests without a valid client certificate
In permissive mode, the domain refuses no client, so a rule in Rules Engine for Firewall must refuse the requests whose client certificate failed the check. The rule acts on the firewall the domain names in edge_firewall_id. To set one, refer to Set a Firewall on a domain.
This rule denies the requests to <your-domain> whose client certificate did not pass validation:
To create the same rule in Azion Console:
In Azion Console, open the firewall the domain names.
Select the Rules Engine tab, then Rule.
Enter a name that says which requests the rule refuses.
In Criteria, select the variable Host and the operator is equal, and enter your domain as the argument.
Select And, then the variable Client Certificate Validation and the operator is not equal. The argument is a list with one entry, Valid, which arrives selected.
In Behavior, select Deny (403 Forbidden).
Select Save.
For every variable, operator, and behavior a firewall rule takes, refer to Rules Engine for Firewall.
Once the rule propagates, a request to <your-domain> without a valid client certificate receives 403 Forbidden. A client whose certificate the Trusted CA signed still reaches the application.
Pass client certificate details to the origin
The Open Banking model requires the origin to receive the client certificate in request headers, from the variables ${ssl_client_escaped_cert} and ${ssl_client_s_dn_parsed}. ${ssl_client_escaped_cert} holds the client certificate as a URL-encoded PEM string, and ${ssl_client_s_dn_parsed} holds its subject Common Name (CN). A Request Phase rule in Rules Engine for Applications adds each header with the add_request_header behavior, on the application the domain names.
This rule adds the client certificate to every request that carries one, in the Escaped-Client-Cert header:
The header argument takes the form Header-Name: value, and Azion Console refuses any other shape with Header must follow the header-name: value format. Add a second rule of the same shape for ${ssl_client_s_dn_parsed}, under a header name of your choice.
To create the same rule in Azion Console:
Access Azion Console > Applications, and select the application the domain names.
Select the Rules Engine tab, then + Rule.
Enter a name that says which header the rule adds.
In the Phase section, select Request Phase. The choice is final once the rule is created.
In Criteria, select the variable ${ssl_client_escaped_cert} and the operator exists.
In Behavior, select Add Request Header and enter Escaped-Client-Cert: ${ssl_client_escaped_cert} as the argument.
Select Save.
For every variable and behavior an application rule takes, refer to Rules Engine for Applications. The other client certificate variables are listed in mTLS variables.
Once the rules propagate, each request that Azion sends to the origin for a client with a certificate carries the headers.