May First Cerificate Authority
While May First mostly depends on Lets Encrypt for our PKI infrastructure, we do operate our own certificatte authority for signing certificates in our dev and/or testing environment and for internal only connections.
The certificate authority key is saved in our ansible vault using the variable
name vault_mfca_key and the signed certificate key is stored in the variable
mayfirst_mfca_cert.
The certificate is saved to the directory
/usr/local/share/ca-certificates/mfca.crt, which is picked up by the
ca-certificates debian package and incorporated into the /etc/ssl/certs
directory so all local applications will trust certificates signed by our key.
The certificate is generally signed for 3 years which means it needs to be periodically renewed.
To renew it:
- Extract the private key (the value of the variable
vault_mfca_key) by runningansible-vault edit secrets.ytmland save to a file calledmfca.key. - Copy the value in
hosts.ymlwith variable namemayfirst_mfca_certo a file namedmfca.crt. - Create a certificate signing request:
openssl x509 -x509toreq -in mfca.crt -signkey mfca.key -out new-server.csr - Create the file
ca.confwith the contents:
[ v3_ca ]
subjectKeyIdentifier=hash
authorityKeyIdentifier=keyid:always,issuer
basicConstraints = critical, CA:true
keyUsage = critical, digitalSignature, cRLSign, keyCertSign
- Sign it:
openssl x509 \
-req \
-extensions v3_ca \
-extfile ca.conf \
-days 1024 \
-in new-server.csr \
-signkey mfca.key \
-out new-cacert.pem`
- Copy new cert over old cert:
mv new-cacert.pem mfca.crt - Copy contents of
mfca.crtto themayfirst_mfca_certvariable inhosts.yml - Copy to all servers:
sower --live playbook --tags mayfirst-mfca-cert - Optioanlly copy
mfca.crtto your/usr/local/share/ca-certificates/mfca.crtand runsudo dpkg-reconfigure ca-certificatesand import it into your browser.