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.
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.
Initialize the CA
Section titled “Initialize the CA”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.
step ca init \ --deployment-type standalone \ --name "Lab CA" \ --dns localhost \ --address 127.0.0.1:9000 \ --provisioner admin@example.comHere 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. |
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.
Look at what it made
Section titled “Look at what it made”ls $(step path)certs config db secrets templatescertsholds the public root and intermediate certificates. Share these freely.secretsholds the private keys. Never share these.config/ca.jsonis the CA’s configuration. You’ll edit it in later modules.dbis the CA’s database. It records issued and revoked certificates.
Start the CA server
Section titled “Start the CA server”Start step-ca with the config it just wrote. Enter your CA password when asked.
step-ca $(step path)/config/ca.jsonStarting Smallstep CA/0.30.2 (linux/amd64)Config file: /home/ubuntu/.step/config/ca.jsonThe primary server URL is https://localhost:9000Root certificates are available at https://localhost:9000/roots.pemX.509 Root Fingerprint: 0681c596b1048ed34c10c4f1e67aff7c79b0a411e092f146edd3e75618f19bd5Serving HTTPS on 127.0.0.1:9000 ...Each real log line also starts with a date and time. Leave this terminal running.
Check it’s healthy
Section titled “Check it’s healthy”Open a second terminal and ask the CA for its health status:
curl --cacert $(step path)/certs/root_ca.crt https://localhost:9000/health{"status":"ok"}--cacert tells curl to trust your new root for this one request. Your system doesn’t trust it yet.
Look inside your root
Section titled “Look inside your root”step certificate inspect $(step path)/certs/root_ca.crt --shortX.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:13ZNotice 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:
step certificate inspect $(step path)/certs/root_ca.crt 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:TRUEmarks it as a CA. Without it, clients refuse anything it signs. pathlen:1allows one CA below it, your intermediate. The intermediate haspathlen:0, so it can sign leaves but not other CAs.
Break it
Section titled “Break it”Forget to trust the root
Section titled “Forget to trust the root”Run the health check without --cacert:
curl https://localhost:9000/healthcurl: (60) SSL certificate problem: unable to get local issuer certificatecurl 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.
Start the CA twice
Section titled “Start the CA twice”With the CA still running, start it again in another terminal:
step-ca $(step path)/config/ca.jsonError 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 unavailableOnly 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.
Use the wrong password
Section titled “Use the wrong password”Stop the CA with Ctrl+C. Start it again and type the wrong password:
step-ca $(step path)/config/ca.jsonerror decrypting /home/ubuntu/.step/secrets/intermediate_ca_key: x509: decryption password incorrectstep-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.
Where to go next
Section titled “Where to go next”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.
Go deeper
Section titled “Go deeper”- step-ca documentation
step ca initreference- step-ca production considerations
- RFC 5280, section 4.2.1.9 — Basic Constraints and path length.
- step-ca source code
Check yourself
Tap a card to flip it. Nothing is scored or saved.
Progress is saved in this browser only.