Building A Root CA and An Intermediate CA Using OpenSSL and Debian Stretch - Dad Hacks PDF
Building A Root CA and An Intermediate CA Using OpenSSL and Debian Stretch - Dad Hacks PDF
Building A Root CA and An Intermediate CA Using OpenSSL and Debian Stretch - Dad Hacks PDF
HOW-TOS, LINUX
A bit of background
A Root Certificate Authority is used to issue digital certificates to servers, clients or users. It generates digital certificates that
certify the ownership of a public key, allowing others to trust the certificate.
An Intermediate Certificate is a subordinate certificate issued by a Root certificate authority for the purpose of issuing certifi-
cates. This creates a certificate chain that begins in the Root CA, through the intermediate and ending in the issued certifi-
cate. This establishes a chain of trust that can verify the validity of a certificate.
In this post, we will step through the process of creating a Root CA, then an Intermediate CA and finally sign digital certificates
for a server. A bit of warning, this setup should be sufficient for a homelab or a small local setup; you should not use this as a
production service.
Prepare to build
Install Debian Stretch, the minimum should suffice. There is no need any GUI. Install SSH for ease of administration and to
transfer you certificates securely out.
Make sure that the Fully Qualified Domain Name of the computer is set correctly.
If you wish you can install ntp to ensure time is always correct.
openssl_root.cnf
openssl_intermediate.cnf
openssl_csr_san.cnf
# mkdir /root/ca
# cd /root/ca
While at /root/ca we should also create “index.txt” file for OpenSSL to keep track of all signed certificates and the “serial” file
to give the start point for each signed certificate’s serial number. This can be accomplished by doing the following:
# cd /root/ca
# touch index.txt
# touch index.txt.attr
Copy openssl_root.cnf to /root/ca, edit it and look for the following entries:
private_key = $dir/private/ca.DOMAINNAME.key.pem
certificate = $dir/certs/ca.DOMAINNAME.cert.pem
crlnumber = $dir/crlnumber
crl = $dir/crl/ca.DOMAINNAME.crl.pem
crl_extensions = crl_ext
default_crl_days = 30
Change DOMAINNAME to something that matches the domain of your network, this isn’t strictly necessary but it makes for a
more customized naming convention.
# cd /root/ca
# openssl req -config openssl_root.cnf -new -x509 -sha512 -extensions v3_ca -key
/root/ca/private/ca.DOMAINNAME.key.pem -out /root/ca/certs/ca.DOMAINNAME.crt.pem -days 3650 -set_serial 0
Ensure that when filling out the “Common Name” variable that you use the CA server + Domain name of the network
# mkdir /root/ca/intermediate
Also all the directories and files needed to support (similar to the ones we created for the Root CA):
# cd /root/ca/intermediate
# touch index.txt
# touch index.txt.attr
Copy openssl_intermediate.cnf to /root/ca/intermediate, edit it and look for the following entries:
private_key = $dir/private/int.DOMAINNAME.key.pem
certificate = $dir/certs/int.DOMAINNAME.crt.pem
crlnumber = $dir/crlnumber
crl = $dir/crl/int.DOMAINNAME.crl.pem
crl_extensions = crl_ext
default_crl_days = 30
Creating the private key and certificate signing request for the Intermediate CA
(change DOMAINNAME to the value you’ve been using so far)
# cd /root/ca
In /root/ca/intermediate/certs, chain.DOMAINNAME.crt.pem is the concatenation of the Root CA certificate and the Inter-
mediate CA certificate.
# cd /root/ca
Creating the certificate by signing the signing request with the intermediate CA
(change “www.example.com” to your server’s FQDN)
# cd /root/ca
In /root/ca/intermediate/certs you should now have a certificate for use in the server (www.example.com in the case of the
example).
CA CERTIFICATE CERTIFICATE REQUEST CRYPTOGRAPHY DEBIAN STRETCH INTERMEDIATE CERTIFICATE AUTHORITY KEYS