Skip to content

πŸ› οΈ Ready to Build?

Apply what you’ve learned and deploy Keycloak on Cloud-IAM.

Try Cloud-IAM

mTLS Certificates and CRL Agent on Keycloak ​

mTLS certificates and CRL Agent
Cloud-IAM Console - mTLS certificates and CRL Agent

What are mTLS and CRL in Keycloak? ​

mTLS (Mutual TLS) is a security protocol where both the client and the server authenticate using certificates. Unlike standard TLSβ€”where only the server proves its identityβ€”mTLS ensures that only trusted applications, services, or devices can reach Keycloak. This adds a strong validation layer before any authentication flow begins.

CRL (Certificate Revocation List) is a list of certificates that should no longer be trusted because they were compromised, disabled, or removed from use. Keycloak’s CRL Agent regularly retrieves and updates these lists from your PKI. During the mTLS handshake, it checks whether the presented certificate is valid or revoked. If the certificate appears in the CRL, Keycloak immediately blocks the connection.

Together, mTLS + CRL ensure that only verified and non-revoked clients can communicate with Keycloak.

Usage and Use Cases of mTLS in Keycloak ​

mTLS adds a strong security layer to Keycloak by validating the client certificate before any access is allowed. By enforcing the β€œSomething You Have” factor through a device-bound certificate, mTLS can even replace username/password login entirely when configured in strict mode.

Beyond stronger security, mTLS also simplifies onboarding new applications or APIs: instead of configuring passwords or shared secrets, access is granted through certificate-based trust, offering a safer and more scalable alternative.

IAM Use Cases ​

CIAM (Customer IAM) ​

  • Restrict access to trusted customer applications
  • Block spoofed or malicious apps early
  • Reduce fraud and protect customer accounts

WIAM (Workforce IAM) ​

  • Allow access only from managed corporate devices
  • Protect internal and administrative applications
  • Reduce insider risks and unauthorized surface exposure

Identity Provider Brokering ​

  • Authenticate external IdPs using certificates
  • Prevent spoofed IdPs and man-in-the-middle attacks
  • Strengthen cross-domain trust relationships

Technical Use Cases ​

  • Microservices / M2M: Secure internal API and service-to-service calls
  • Admin Tools & Automation: Authenticate scripts or admin tools without passwords

Security considerations and user impact of mTLS ​

While mTLS significantly improves security, it also introduces friction for end users and client applications (e.g.: losing a certificate means losing access, users cannot authenticate from unmanaged devices, IT teams must generate and distribute certificates, etc.).

These constraints reflect the usual balance between stronger security and operational convenience, the appropriate level depends on each organization’s context and security requirements.

How to upload your mTLS certificates in the Cloud-IAM Console ​

In this article, we will assume that you already created your certificate .crt .cer.

  1. Open Cloud-IAM console
  2. Select the Keycloak deployment you want to configure.
  3. Click on Customisation
  4. Then select mTLS to start the configuration
  5. Click Upload
  6. Select the file containing your certificate (for example: acme-v1.0.crt)
  7. Toggle the option to either apply now and trigger a restart or don't and upload now and restart later.
  8. Then click Upload to confirm

After 5–10 minutes, while your Keycloak deployment redeploys via the rolling upgrade process, the changes will be applied. Your mTLS certificates are now uploaded to your deployment.

Cloud-IAM Console - Upload mTLS certificates
Cloud-IAM Console - Upload mTLS certificates

How to configure Strict mTLS for Keycloak ​

Introduction ​

This tutorial explains how to configure strict mTLS for your Keycloak deployment. In a strict mTLS setup, every client must present a valid X.509 certificate before accessing Keycloak.

This mode is useful when:

  • You want to enforce strong authentication for all clients
  • Your environment requires strict verification of device or application identity
  • You must block all unauthenticated connections at the network edge
  • You want to prevent access from unmanaged or unknown devices entirely

Identity Mapping Assumption ​

For this tutorial, we assume that your client certificate contains an email field (either in the Subject or in the Subject Alternative Name – SAN). This email allows Keycloak to map the incoming certificate to the correct user account during authentication.

Login behavior with strict mTLS ​

If the client does not send a certificate, or if the certificate is invalid, the connection is blocked directly at the load balancer, before it reaches Keycloak. If the certificate is valid, the load balancer approves the connection and forwards the request to Keycloak for identity mapping and authentication. For more details on how a Managed Keycloak deployment architecture with Load Balancer and Keycloak, see the architecture insight.

This guide assumes ​

Scope of This Tutorial ​

This tutorial focuses on how to configure optional mTLS within Keycloak and the Cloud-IAM Console. This tutorial does not cover all the necessary security best practices for a complete configuration, it's a build to guide you through one specific process.

Step 1 - How to set a custom domain with mTLS as Strict ​

In this step, you configure your custom domain so it enforces strict mTLS at the load balancer level. This ensures Keycloak only receives requests from clients presenting a valid certificate.

  1. Open Cloud-IAM console
  2. Select the Keycloak deployment you want to configure.
  3. Click on Configuration
  4. Select the ✎ Edit icon next to the custom domain you want to secure with strict mTLS.
  5. Enable the mTLS toggle.
  6. Select Strict, then click Save to confirm.
Cloud-IAM Console - Set mTLS Custom Domains as Strict
Cloud-IAM Console - Set mTLS Custom Domains as Strict

Step 2 - How to duplicate your browser flow on Keycloak ​

Keycloak does not allow editing the default Browser flow, so you must duplicate the browser flow before making changes.

  1. Log in to your Keycloak as an admin
  2. Select the realm where you want to apply mTLS certifications
  3. Navigate to Authentication
  4. Select ... from the Browserline
  5. Click on Duplicate (3.)
  6. Name the new browser flow (e.g. browser-mtls)
Keycloak Console - Duplicate browser flow mTLS
Keycloak Console - Duplicate browser flow for mTLS

Step 3 - How to add steps mTLS on Keycloak authentication flow ​

In this step, you add the X.509 authenticator so Keycloak can extract the email from the certificate and identify the user.

  1. Open the newly created Browser flow (e.g. browser-mtls)
  2. Select Add Execution
  3. Search from the list X509/Validate Username Form, select it, and click Add
  4. Reorder the executions so X509/Validate Username Form is placed just below the Cookie and above Kerberos step
  5. Set the execution requirement to Required
Keycloak Console - Strict Browser flow mTLS expected
Keycloak Console - Strict Browser flow mTLS expected

Step 4 - How to configure mTLS x509 on Keycloak authentication flow as strict ​

In this step, you configure Keycloak to extract the email from the certificate and map it to the correct Keycloak user.

  1. Select the βš™οΈ next to X509/Validate Username Form to open the control panel
  2. Name X509/Validate Username Form config on Alias (e.g. mtls-email)
  3. From User Identity Source list click on Subject's e-mail
  4. From User mapping method list click on Username or Email
  5. Optional: if you don't want confirmation screen toggle On Bypass identity confirmation line
  6. Verify the toggle is ON that Check certificate validity
  7. Then click Save to validate this new execution
Keycloak Console - Configure mTLS x509 settings on Keycloak
Keycloak Console - Configure mTLS x509 settings on Keycloak

Step 5 - How to bind the new mTLS browser flow ​

In this step, you activate your new authentication flow so it becomes the default browser flow for the realm.

  1. Navigate to Authentication
  2. Select ... from the browser-mtls line
  3. Click on Bind flow
  4. Then select Browser flow and click on Save

Your Keycloak realm now uses the mTLS-enabled flow.

Keycloak Console - Bind the new mTLS browser flow
Keycloak Console - Bind the new mTLS browser flow

Conclusion ​

You have now successfully enabled strict mTLS authentication for Keycloak on your realm. All incoming connections must now present a valid certificate, and Keycloak will authenticate users based on the email contained in that certificate.

How to configure Optional mTLS for Keycloak ​

Introduction ​

This tutorial explains how to configure optional mTLS for your Keycloak deployment. In an optional mTLS setup, clients may present a valid X.509 certificate, but it is not required to access Keycloak or the application behind.

This mode is useful when:

  • You want to gradually roll out mTLS without breaking existing access
  • Your environment mixes managed devices (with certificates) and unmanaged ones
  • You need strong authentication when possible, while allowing standard login flows for the rest

Identity Mapping Assumption ​

For this tutorial, we assume that your client certificate contains an email field (either in the Subject or in the Subject Alternative Name – SAN). This email allows Keycloak to map the incoming certificate to the correct user account during authentication.

Login behavior with optional mTLS ​

If the client sends a valid certificate, the load balancer validates it and forwards the request to Keycloak. Keycloak then authenticates the user using the email extracted from the certificate. If the client does not send a certificate, or sends an invalid certificate, the load balancer still forwards the request to Keycloak. Keycloak then continues with the regular login flow (username/password, identity provider redirect, etc.).

This allows your deployment to support heterogeneous environments with different levels of security. For more details on how a Managed Keycloak deployment architecture with Load Balancer and Keycloak, see the architecture insight.

This guide assumes ​

Scope of This Tutorial ​

This tutorial focuses on how to configure optional mTLS within Keycloak and the Cloud-IAM Console. This tutorial does not cover all the necessary security best practices for a complete configuration, it's a build to guide you through one specific process.

Step 1 - How to set a custom domain with mTLS as Optional ​

In this step, you configure your custom domain so it enforces optional mTLS at the load balancer level. This ensures Keycloak only receives all requests from clients.

  1. Open Cloud-IAM console
  2. Select the Keycloak deployment you want to configure.
  3. Click on Configuration
  4. Select the ✎ Edit icon next to the custom domain you want to secure with optional mTLS.
  5. Enable the mTLS toggle.
  6. Select Optional, then click Save to confirm.
Cloud-IAM Console - Set mTLS Custom Domains as Optional
Cloud-IAM Console - Set mTLS Custom Domains as Optional

Step 2 - How to duplicate your browser flow on Keycloak ​

Please refer to Step 2 of strict mTLS tutorial.

Step 3 - How to add steps mTLS on Keycloak authentication flow ​

In this step, you add the X.509 authenticator so Keycloak can extract the email from the certificate and identify the user if he has one.

  1. Open the newly created Browser flow (e.g. browser-mtls)
  2. Select Add Execution
  3. Search from the list X509/Validate Username Form, select it, and click Add
  4. Reorder the executions so X509/Validate Username Form is placed just below the Cookie and above Kerberos step
  5. Set the execution requirement to alternative
Keycloak Console - Optional Browser flow mTLS expected
Keycloak Console - Optional Browser flow mTLS expected

Step 4 - How to configure mTLS x509 on Keycloak authentication flow as optional ​

Please refer to Step 4 of strict mTLS tutorial.

Step 5 - How to bind the new mTLS browser flow ​

Please refer to Step 5 of strict mTLS tutorial.

Conclusion ​

You have now successfully enabled optional mTLS authentication for Keycloak on your realm. This mode provides the benefits of certificate-based authentication only when certificates are available, while still supporting standard login methods for users, applications, or devices that do not use mTLS yet.

How to manage the CRL Agent List ​

This feature is currently under active development and is not yet available through the Cloud-IAM Console.

If you need to configure or update your CRL Agent list, please contact our support team. Our engineers will assist to apply the configuration on your Keycloak deployment.