PKI Unified CRL and OCSP with cross cluster revocation
Requires Vault Enterprise
The PKI secrets engine unified CRL and OCSP, and cross cluster revocation features demonstrated here require a Vault Enterprise license.
A PKI secrets engine in Vault servers at versions before 1.13.0 writes certificate revocation data to the cluster that issues a certificate. This means revocations which require information from the issued certificate must also occur on that same local cluster.
The challenge for end-users in Performance Replication environments becomes tracking which cluster issued a given leaf certificate to verify validity or revoke the certificate by its serial number.
Solution
Vault Enterprise version 1.13.0 introduces new opt-in features which help resolve this challenge:
Unified CRL and OCSP functionality across clusters. Enabling this feature results in an eventually consistent, globally unified CRL based on the revocation entries of all clusters. With this feature enabled, Vault writes revocation entries from each cluster locally to the cluster that issued the certificate. It then also writes a revocation entry to the primary cluster that replicates across all Vault clusters.
Asynchronous cross cluster revocation. When you opt in to this feature, you gain the ability to revoke certificates from clusters other than the issuing cluster.
Scenario introduction
In this scenario, you will configure and start 2 Vault Enterprise servers, which will act as the Performance Replication primary and secondary clusters.
You will use the Vault CLI to enable and configure 4 PKI Secrets Engine instances along with a username and password auth method.
You will also use the Vault CLI to enable Performance Replication between the 2 servers and issue leaf certificates from each of the 4 secrets engine roles.
To wrap up, you will query and revoke the certificates to learn more about the unified CRL and OCSP, and cross cluster revocation features.
Personas
The steps described in this tutorial are typically performed by a security engineer.
Prerequisites
To perform the tasks described in this tutorial, you need:
- A Vault Enterprise binary v1.13.0 or later installed and in your system
PATH
.- Vault token with policies to manage Performance Replication and secrets engines (this tutorial uses the initial root token).
- jq binary installed and in system
PATH
for parsing JSON in terminal sessions. - A text editor that you can use in terminal sessions to edit scripts.
- openssl binary installed and in system
PATH
for validating certificates. If your OS distribution provides anopenssl
binary, you can use it for this tutorial. - Familiarity with the Vault Enterprise Performance Replication feature; if you are not familiar, you can learn more in Setting up Performance Replication.
- Familiarity with the Vault PKI Secrets Engine; if you are not familiar, you can learn more in Build Your Own Certificate Authority (CA).
Lab setup
The lab for this scenario is a simplified Performance Replication setup made up of 2 Vault Enterprise servers, which represent the primary and secondary clusters.
You will prepare the environment by making directories and writing configuration files.
You will then initialize, and unseal the Vault server for each cluster.
For the sake of simplicity in this lab, you will use the initial root token for all steps in this scenario.
Create lab home
You can create a temporary directory to hold all the content needed for this scenario, and then assign its path to an environment variable for later reference.
Open a terminal, and create the directory /tmp/learn-vault-pki
.
Export the directory path as the value to the HC_LEARN_LAB
environment variable.
Set up primary cluster server
The primary cluster server uses Integrated Storage and listens on 127.0.0.1:8200
for client communications.
Export your Vault Enterprise license string as the value of the
VAULT_LICENSE
environment variable.Create the primary server configuration and data directories.
Write the primary server configuration file.
Start the primary cluster Vault server.
Open another terminal session, and use it to export an environment variable for the
vault
CLI to address the primary server.For the purposes of this scenario, you can initialize the server with just 1 key share and a key threshold of 1. Redirect the initialization information to the file
$HC_LEARN_LAB/primary-cluster/.init
.Export the primary cluster server unseal key as the value to the
PRIMARY_UNSEAL_KEY
environment variable.Unseal the primary cluster server.
Example expected output:
The primary cluster server is ready.
Set up secondary cluster server
The secondary cluster server uses Integrated Storage and listens on 127.0.0.1:8210
for client communications.
Export your Vault Enterprise license string as the value of the
VAULT_LICENSE
environment variable.Create the secondary server configuration and data directories.
Write the secondary server configuration file.
Start the secondary cluster server.
Open another terminal session, and in that one, export the directory path as the value to the
HC_LEARN_LAB
environment variable.Change into the lab directory.
Export an environment variable for the
vault
CLI to address the secondary cluster server.For the purposes of this scenario, you can initialize the server with just 1 key share and a key threshold of 1. Redirect the initialization information to the file
$HC_LEARN_LAB/secondary-cluster/.init
.Export the secondary cluster server unseal key as the value to the
SECONDARY_UNSEAL_KEY
environment variable.Unseal the secondary cluster server.
Example expected output:
The secondary cluster server is ready.
Enable PKI secrets engines on primary cluster server
The goal of this section is for you to enable and configure 4 instances of the PKI secrets engine, each with a different set of features available.
This way, you can learn about revocation behaviors in each case.
You will use a script to enable the following named secrets engine engines on the primary server:
- pki-local: No unified revocation features enabled.
- pki-unified: You will enable the unified CRL feature.
- pki-cross: You will enable both unified CRL and cross cluster revocation features.
Export an environment variable for the
vault
CLI to address the primary server.Export the primary cluster server initial root token as the value to the
VAULT_TOKEN
environment variable.To save time and typing, you will use a script to enable and configure secrets engines based on steps like those in Build Your Own Certificate Authority (CA).
Use a text editor to write and save the example shell script content to the file
enable_engines.sh
.enable_engines.shMake the script executable.
Execute the script to enable and configure the secrets engines.
Abbreviated expected output:
List enabled secrets engines.
Example expected output:
Configure PKI secrets engines
The unified CRL and OCSP, and cross cluster revocation features are opt-in.
When you wrote and ran the shell script that enables and configures the PKI secrets engines, it did not configure the secrets engines with the new features. This means that 3 of the 4 PKI secrets engines require configuration updates. You can update them through the Set Revocation Configuration API endpoint.
The goal of this section is to learn about these configuration parameters, and apply them to the 3 secrets engines which require configuration updates.
Tip
If you need further details about these parameters, refer to their API documentation:
Check the current CRL configuration for the
pki-int-unified
secrets engine.Example expected output:
Recall that the features covered in this tutorial are opt-in, so
unified_crl
isfalse
as expected.The
pki-int-unified
secrets engine needs configuration to use just the unified CRL and OCSP feature and allow it for existing paths. Enabling this feature requires that you also set theauto_rebuild
parameter totrue
, as unified CRLs cannot be rebuilt on every revocation.Example expected output:
The
pki-int-cross
secrets engine needs configuration to use just the cross cluster revocation feature. Enabling this feature requires that you also set theauto_rebuild
parameter totrue
, as the local cluster may not have the certificate entry whenauto_rebuild
is not enabled.Example expected output:
The
pki-int-both
secrets engine needs configuration to use both the unified CRL and OCSP, and cross cluster revocation features. Since this secrets engine combines both features, you must also set theauto_rebuild
parameter totrue
.Example expected output:
You have completed the PKI secrets engine configuration, and the PKI secrets engines are ready for certificate issuance.
Enable Performance Replication
The goal of this section is for you to enable a userpass auth method instance, a user and password, and Performance Replication between the primary and secondary cluster servers.
Primary server
Before enabling performance replication, create a superuser
policy and enable
userpass auth method with tester
user on the primary cluster.
Create a
superuser
ACL policy.Enable the
userpass
auth method.Create a new user named
tester
in userpass with the passwordchangeme
, and attach thesuperuser
policy.
Later, you can authenticate with Vault using the userpass auth method.
Use the CLI to enable Performance Replication on the primary and secondary servers.
Enable replication on the primary cluster server.
Example expected output:
Generate a secondary activation token and assign its value to the
SECONDARY_ACTIVATION_TOKEN
environment variable.This command is not expected to produce output, but you can verify the environment variable if you like.
Expected example output:
Secondary server
Export an environment variable for the
vault
CLI to address the secondary server.Export the secondary cluster server initial root token as the value to the
VAULT_TOKEN
environment variable.Enable replication on the secondary server with the secondary activation token.
Warning
This will clear all data in the secondary cluster!
Expected example output:
Issue certificates
The goal of this section is for you to issue a leaf certificate from each of the PKI secrets engine roles on the secondary cluster server.
You can then try revoking the certificates and observing the different behaviors across each PKI secrets engine instance.
Unset the
VAULT_TOKEN
environment variable.Before issuing the certificates, you must first use the userpass auth method to authenticate with the secondary cluster server.
This command produces no output, but you can confirm that the token helper cached the token value by displaying part of it.
Example expected output:
Tip
If you meet with an error message containing
* local node not active but active cluster node not found
, when you try to login with the userpass auth method this means that the replication hasn't finished syncing. Wait a moment and try the command again.Issue a certificate from the pki-int-local PKI secrets engine
local-example-dot-com
role.Store the serial number in a
test.local.example.com.serial.txt
file.Store the certificate in the
test.local.example.com.crt
file.Issue a certificate from the pki-int-unified PKI secrets engine
unified-example-dot-com
role.Store its serial number in the
test.unified.example.com.serial.txt
file.Store the certificate in the
test.unified.example.com.crt
file.Issue a certificate from the pki-int-cross PKI secrets engine
cross-example-dot-com
role.Store its serial number in the
test.cross.example.com.serial.txt
file.Store the certificate in the
test.cross.example.com.crt
file.Issue a certificate from the pki-int-both PKI secrets engine
both-example-dot-com
role.Store its serial number in the
test.both.example.com.serial.txt
file.Store the certificate in the
test.both.example.com.crt
file.
Explore behavior without features
The goal of this section is for you to query and revoke the leaf certificate from the pki-int-local PKI secrets engine. In doing so, you learn more about the PKI secrets engine behavior without the unified CRL and OCSP feature.
Use
openssl
to query the secondary cluster server OCSP about the certificate that you issued from the pki-int-local PKI secrets engine.Example expected output:
According to the secondary cluster OCSP, the certificate is valid.
Try revoking the certificate by its serial number through the primary cluster server. For convenience, you can set the environment variables for the primary cluster server and token as part of the command.
Instead of success, Vault outputs an error:
The primary cluster is not aware of the certificate issued from the secondary cluster. This demonstrates correct and expected behavior from the
pki-int-local
secrets engine, since it isn't configured with support for unified CRL and OCSP.Try revoking the certificate by its serial number through the secondary cluster server. For convenience, you can set the environment variables for the secondary cluster server and token as part of the command.
The certificate state shows a value of revoked.
You revoked the certificate.
Explore unified CRL & OCSP behavior
The goal of this section is for you to revoke the leaf certificate from the pki-int-unified PKI secrets engine. Then, you will check the list of revoked certificates on the secondary cluster server and primary cluster server. In doing so, you learn more about the PKI secrets engine behavior with the unified CRL and OCSP feature enabled.
Use
openssl
to query the secondary cluster server OCSP about the certificate that you issued from the pki-int-unified PKI secrets engine.Example expected output:
According to the secondary cluster OCSP, the certificate is valid.
Revoke the certificate by its serial number through the secondary cluster server. For convenience, you can set the environment variables for the secondary cluster server and token as part of the command.
You revoked the certificate.
List revoked certificates on the secondary cluster server.
Example expected output:
You revoked the certificate.
Without the unified CRL and OCSP feature, you cannot expect the primary cluster server to have knowledge of the certificate. With it enabled, the primary cluster server should also show the certificate as revoked.
Use
openssl
to query the primary cluster server OCSP about the certificate.Example expected output:
With unified CRL and OCSP, the secondary cluster server now also shows the certificate revocation.
Explore cross cluster revocation behavior
The goal of this section is for you to revoke the leaf certificate from the pki-int-cross PKI secrets engine. In doing so, you learn more about the PKI secrets engine behavior with the cross cluster revocation feature enabled.
Use
openssl
to query the secondary cluster server OCSP about the certificate that you issued from the pki-int-cross PKI secrets engine.Example expected output:
According to the secondary cluster OCSP, the certificate is valid.
Try to revoke the certificate by its serial number through the primary cluster server. For convenience, you can set the environment variables for the primary cluster server and token as part of the command.
Example expected output:
Vault warns that it did not find a revocation request on the primary cluster server, and that the request is now pending. This means that with cross cluster revocation enabled, the secondary will learn of the request and revoke the certificate.
Try querying the secondary cluster server for the certificate from
pki-int-cross
.Example expected output:
The cross cluster revocation functionality revoked the certificate.
Explore unified CRL & OCSP with cross cluster revocation behavior
The goal of this section is for you to revoke the leaf certificate from the pki-int-both PKI secrets engine from the secondary cluster server. You will then query the certificate with OCSP from the primary cluster server. In doing so, you learn more about the PKI secrets engine behavior with both the unified CRL and OCSP, with cross cluster revocation features enabled.
Use
openssl
to query the secondary cluster server OCSP about the certificate that you issued from the pki-int-both PKI secrets engine.Example expected output:
According to the secondary cluster OCSP, the certificate is valid.
Try to revoke the certificate by its serial number through the primary cluster server. For convenience, you can set the environment variables for the primary cluster server and token as part of the command.
Example expected output:
Vault warns that it did not find a revocation request on the primary cluster server, and that the request is now pending. This means that with cross cluster revocation enabled, the secondary will learn of the request and revoke the certificate.
Try querying the secondary cluster server for the certificate from
pki-int-both
.Example expected output:
Use
openssl
to query the primary cluster server OCSP about the certificate.Example expected output:
The cross cluster revocation functionality revoked the certificate. Both the primary and secondary server clusters are aware of the revocation.
Summary
You established a lab environment with PKI secrets engines, the userpass auth method, and Performance Replication enabled.
You also learned about the PKI secrets engine unified CRL and OCSP, and cross cluster revocation features and their capabilities by issuing, querying, and revoking certificates.
Usage caveats
Size limitations exist for individual entries within Vault depending on the chosen storage backend.
If your use cases accumulate a large quantities of revoked certificates across various clusters, the unified CRL could hit limits and become unusable.
If a large amount of revocations are occurring, the traffic from the additional writes across all the clusters and/or the background/periodic threads within Vault could overload resources.
Consult Vault Limits and Maximums for more details.
Clean up
Stop the Vault server processes.
Change into your home directory.
Remove the lab directory.
Unset the environment variables.
Close any unneeded terminal sessions.
Next steps
To continue learning about the Vault PKI secrets engine or Performance Replication, check out the following tutorials:
- Build Certificate Authority (CA) in Vault with an offline Root
- PKI Secrets Engine with Managed Keys
- HCP Vault Dedicated Performance Replication