Skip to main content
Welcome to this hands-on guide for Vault’s PKI Secrets Engine. In this tutorial, you will:
  • Deploy a root Certificate Authority (CA) in Vault
  • Create and sign an intermediate CA
  • Define a role for issuing certificates
  • Request certificates from the intermediate CA
Follow along with the full HashiCorp Learn tutorial: Building Your Own Certificate Authority (CA) Using Vault.
The image shows a webpage from HashiCorp Learn about building your own Certificate Authority (CA) using Vault. It includes a navigation menu and a list of steps for the process.
  • A running Vault cluster (we’ll use AWS).
  • Vault CLI installed and authenticated.
  • jq installed for JSON parsing.

Step-by-Step Overview


1. Enable and Tune the Root PKI Engine

First, verify no PKI engine is enabled:
Enable the root PKI engine and set its maximum lease TTL to 10 years:

2. Generate the Root Certificate

Create an internal root CA certificate. This outputs only the PEM-format certificate:
Confirm the file:

3. Configure CA and CRL Distribution URLs

Point Vault to the endpoints where clients can retrieve the issuing CA and CRL:

4. Enable and Tune the Intermediate PKI Engine

Remove any existing intermediate engine, then enable a fresh one with a 5-year TTL:

5. Generate the Intermediate CSR

Have the intermediate engine generate a private key and CSR. Extract the CSR to a file:
Verify both the CA and CSR files:

6. Sign the Intermediate CSR with the Root

Submit the CSR to the root engine and save the signed intermediate certificate:

7. Import the Signed Intermediate Certificate

Configure the intermediate engine to use its signed certificate:

8. Create a Role for Issuing Certificates

Define a role named vaultadvanced that can issue certificates for vaultadvanced.com and its subdomains:
Verify the new role:

9. Issue a Certificate from the Intermediate

Request a certificate with a 24-hour TTL:
The private_key is only returned at issuance. Store it securely, as Vault will not retain it for later retrieval.
You can issue additional short-lived certificates, for example:

10. View Engines and Certificates in the Vault Web UI

The image shows a web interface for HashiCorp Vault, displaying a list of secret engines such as "cubbyhole" and "pki." There is a warning about using a root token and a welcome message offering a tour of the Vault Web UI.
In the UI, navigate to pki/ and pki_int/ to inspect roles and issued certificates (serial numbers only, no private keys).

References

Watch Video