Setting Up an Intermediate CA with OpenSSL (and the CA:FALSE mistake)
Setting up an OpenSSL intermediate CA in its own LXC container, including the CA:FALSE mistake that Sophos rejected, moving certificates between containers with pct, and choosing consistent subject names.
In the previous post, we built the CRL distribution endpoint (ct-crl.cs.manzana.home). Now we need the brain of the operation: the Intermediate CA (ct-intermediate-ca.cs.manzana.home).
Creating a Root CA is easy. Creating an Intermediate CA that actually works? That’s where things get spicy.
The Directory Structure
OpenSSL is pedantic. It expects specific files to exist before it will do anything. On ct-intermediate-ca, we set up the classic structure:
/pki/ca/intermediate/
├── certs/
├── crl/
├── newcerts/
├── private/ # chmod 700 absolutely mandatory here
├── index.txt # Must be empty initially
├── serial # e.g., "1000"
└── crlnumber # e.g., "1000"
The Config File (openssl.cnf)
You need to tell OpenSSL what kind of monster it’s creating. The [ CA_default ] section defines the paths, but the real magic happens in the extensions.
For the Intermediate CA itself, we need the v3_intermediate_ca section:
[ v3_intermediate_ca ]
subjectKeyIdentifier = hash
authorityKeyIdentifier = keyid:always,issuer
basicConstraints = critical, CA:true, pathlen:0
keyUsage = critical, digitalSignature, cRLSign, keyCertSign
The Big Mistake: CA:FALSE
Here’s where I messed up. I generated the CSR for the Intermediate CA, sent it to the Root CA, and signed it. Everything looked great—until I tried to import it into the Sophos firewall.
The Sophos spat out an error: “Certificate isn’t a valid CA certificate or can’t be used for signing.”
I ran a quick check:
openssl x509 -in intermediate-ca.crt -noout -text | grep -A1 "Basic Constraints"
Output: CA:FALSE.
Facepalm.
I had forgotten to pass the -extfile parameter when signing. The Root CA had signed the Intermediate CA’s CSR as if it were just a regular end-entity certificate. The fix was simple: re-sign the CSR on the Root CA with the correct extensions file.
openssl x509 -req \
-in /pki/ca/root/certs/intermediate-ca.csr \
-CA /pki/ca/root/certs/root.cert.pem \
-CAkey /pki/ca/root/private/root.key.pem \
-CAcreateserial \
-out /pki/ca/root/certs/intermediate-ca.crt \
-days 1825 -sha256 \
-extfile /pki/ca/root/ext_intermediate.cnf \
-extensions v3_intermediate_ca
Always verify the Basic Constraints before you proceed.
Transferring Files Between Containers
Since the Root CA and Intermediate CA live in different LXC containers, we use Proxmox’s pct command. This is much faster than messing with SSH if you’re already on the host.
# Pull from Root CA - container ID 101
pct pull 101 /pki/ca/root/certs/intermediate-ca.crt /tmp/intermediate-ca.crt
# Push to Intermediate CA - container ID 103
pct push 103 /tmp/intermediate-ca.crt /pki/ca/intermediate/certs/intermediate-ca.crt
The Subject Name Matters
I initially named the Intermediate CA HomeLab Intermediate CA while the Root CA was manzana Root CA. Technically, this works. Practically, it’s a mess. The organization (O=) should match. I fixed this by re-creating the Intermediate CA with O=Manzana, CN=manzana Intermediate CA. It’s a small thing, but it makes the PKI look professional.