Skip to content
Module 02

Build your own CA with step-ca

Stand up a private root and intermediate CA on your own machine using the open-source step-ca.

ToolsBeginner 30 min

Reading about CAs only goes so far. In this lab you’ll run your own, using step-ca, an open-source CA server, and the step command-line tool. Make sure you’ve followed Lab Setup first.

You don’t need any special hardware. A laptop is enough. When you’re ready to harden it, see Where to go next.

step ca init creates a root CA, an intermediate CA, and a config file. It asks you to choose a password for the CA keys. Pick a real one and keep it safe.

terminal
step ca init \
--deployment-type standalone \
--name "Lab CA" \
--dns localhost \
--address 127.0.0.1:9000 \
--provisioner admin@example.com

Here is what each flag does:

Flag Meaning
--deployment-type standalone You run and manage the CA yourself. Without it, step asks.
--name The name that appears in your CA certificates.
--dns The name clients use to reach the CA. It goes in the CA’s own TLS certificate.
--address Where the CA listens. 127.0.0.1 keeps it private to this machine.
--provisioner The name of the first provisioner, a password-protected admin.
Expected output
Generating root certificate... done!
Generating intermediate certificate... done!
✔ Root certificate: /home/ubuntu/.step/certs/root_ca.crt
✔ Root private key: /home/ubuntu/.step/secrets/root_ca_key
✔ Root fingerprint: 0681c596b1048ed34c10c4f1e67aff7c79b0a411e092f146edd3e75618f19bd5
✔ Intermediate certificate: /home/ubuntu/.step/certs/intermediate_ca.crt
✔ Intermediate private key: /home/ubuntu/.step/secrets/intermediate_ca_key
✔ Database folder: /home/ubuntu/.step/db
✔ Default configuration: /home/ubuntu/.step/config/defaults.json
✔ Certificate Authority configuration: /home/ubuntu/.step/config/ca.json
Your PKI is ready to go. To generate certificates for individual services see 'step help ca'.

Your fingerprint will be different. Every new root gets its own.

terminal
ls $(step path)
Expected output
certs config db secrets templates
  • certs holds the public root and intermediate certificates. Share these freely.
  • secrets holds the private keys. Never share these.
  • config/ca.json is the CA’s configuration. You’ll edit it in later modules.
  • db is the CA’s database. It records issued and revoked certificates.

Start step-ca with the config it just wrote. Enter your CA password when asked.

terminal
step-ca $(step path)/config/ca.json
Expected output (excerpt)
Starting Smallstep CA/0.30.2 (linux/amd64)
Config file: /home/ubuntu/.step/config/ca.json
The primary server URL is https://localhost:9000
Root certificates are available at https://localhost:9000/roots.pem
X.509 Root Fingerprint: 0681c596b1048ed34c10c4f1e67aff7c79b0a411e092f146edd3e75618f19bd5
Serving HTTPS on 127.0.0.1:9000 ...

Each real log line also starts with a date and time. Leave this terminal running.

Open a second terminal and ask the CA for its health status:

terminal
curl --cacert $(step path)/certs/root_ca.crt https://localhost:9000/health
Expected output
{"status":"ok"}

--cacert tells curl to trust your new root for this one request. Your system doesn’t trust it yet.

terminal
step certificate inspect $(step path)/certs/root_ca.crt --short
Expected output
X.509v3 Root CA Certificate (ECDSA P-256) [Serial: 2015...2654]
Subject: Lab CA Root CA
Issuer: Lab CA Root CA
Valid from: 2026-11-16T03:58:13Z
to: 2036-11-13T03:58:13Z

Notice the Subject and Issuer are the same — that’s what makes it a self-signed root. It’s valid for 10 years. Your serial number and dates will differ.

Now look at the extensions that make it a CA:

terminal
step certificate inspect $(step path)/certs/root_ca.crt
Expected output (excerpt)
X509v3 extensions:
X509v3 Key Usage: critical
Certificate Sign, CRL Sign
X509v3 Basic Constraints: critical
CA:TRUE, pathlen:1
  • Key Usage says this key may sign certificates and revocation lists. Nothing else.
  • Basic Constraints CA:TRUE marks it as a CA. Without it, clients refuse anything it signs.
  • pathlen:1 allows one CA below it, your intermediate. The intermediate has pathlen:0, so it can sign leaves but not other CAs.

Run the health check without --cacert:

terminal
curl https://localhost:9000/health
Expected output (excerpt)
curl: (60) SSL certificate problem: unable to get local issuer certificate

curl checked the CA’s TLS certificate against your system’s trust store. Your private root isn’t in it. Module 3 shows how another machine gets your root safely.

With the CA still running, start it again in another terminal:

terminal
step-ca $(step path)/config/ca.json
Expected output (excerpt)
Error opening database of Type badgerv2: error opening Badger database: Cannot acquire directory lock on "/home/ubuntu/.step/db". Another process is using this Badger database.: resource temporarily unavailable

Only one step-ca can use the database at a time. If you see this and don’t think a CA is running, look for a forgotten one with pgrep -a step-ca.

Stop the CA with Ctrl+C. Start it again and type the wrong password:

terminal
step-ca $(step path)/config/ca.json
Expected output (excerpt)
error decrypting /home/ubuntu/.step/secrets/intermediate_ca_key: x509: decryption password incorrect

step-ca needs the intermediate key to sign anything, so it won’t start without it. Start it again with the right password before you continue.

Your CA keys are files on disk, protected by a password. That’s the right place to learn. A production CA goes further:

  • Keep the root offline. Use it only to sign or replace intermediates.
  • Put the intermediate key in hardware. A TPM, YubiKey or HSM signs without ever exposing the key. step-ca supports these through its KMS options.
  • Run it as a service under its own user, started by systemd.

Smallstep’s tiny CA with a Raspberry Pi and YubiKey walks through that hardened build end to end. Come back to the next module first. You’ll get more out of it once you’ve issued, renewed and revoked a few certificates yourself.

Check yourself

Tap a card to flip it. Nothing is scored or saved.

Progress is saved in this browser only.