PKI based on step-ca, postgres and docker with ocsp
I use here pki.example.com
as a domain name. You should replace it with your domain name. root
as a name of the Root CA, and int1
as a name of the Intermediate CA.
-
Root CA
https://root.pki.example.com/ca
Root CA Certificatehttp://root.pki.example.com/ocsp
OCSP Responderhttp://root.pki.example.com/crl
CRL
-
Intermediate CA
https://int1.pki.example.com/
Endpoint for StepCAhttp://int1.pki.example.com/ocsp
OCSP Responderhttp://int1.pki.example.com/crl
CRL
-
Create configuration
- run
python scripts generate-data-dir
- set all values in
data/config.json
serverName
- dns name of the server- set
serverName
in your DNS to point to this server
- run
-
Create secrets
- change default database password in
data/secrets/db-password.txt
- change default database password in
-
Start default services
docker compose up -d
-
Setup first Root CA and Intermediate CA
[!IMPORTANT] Remember to update
docker-compose.yml
with new services. Remember to restart the services after changes. -
Now you have fully working PKI with Root CA, and Intermediate CA.
-
remove include from
docker-compose.yml
-
remove files from
data/configs/<name>
anddata/volumes/<name>
-
restart services
Run docker compose up -d --remove-orphans
- remove database
You should remove database manually. You can use docker compose exec -it database psql -U postgres
and then DROP DATABASE "<name>"; DROP USER "<name>";
- If you remove intermediate CA, you should update Root CA with new CRL and OCSP data.
python scripts backup
- backup will be saved in
backup/backup-pki.tar.gz
- script do not backup certificates and keys for proxy and ocsp. You should regenerate them after restore.
- System is not ready for production use.
- You can't use mtls to renew certificates. When you use
step ca renew
you need to provide--mtls=false
flag.
root-ca/format-cert
cuts leading zeros in serial number.