A Private PKI for the Homelab: Two-Tier CA with OpenSSL

How my homelab issues trusted TLS certificates for Proxmox and Sophos from a root CA and an intermediate CA built with OpenSSL, including the directory layout, the issuance workflow, and the weak spots I still plan to fix.

A homelab with several hypervisors, a firewall, and assorted management interfaces ends up with a lot of HTTPS endpoints. Their default certificates are self-signed, so browsers and operating systems don’t trust them. You either click through a warning for every service or run your own certificate authority.

I chose the second option. A small LXC container named ct-microca hosts a private PKI built with OpenSSL, using a classic two-tier layout: a root CA and an intermediate CA. It currently issues certificates for Proxmox and Sophos, under internal names such as proxmox.mgmt.manzana.home.

This post describes how that PKI is organized, how I issue a certificate, and what is still missing.

Architecture: root CA and intermediate CA

The PKI has two certificate authorities:

  1. Root CA: the trust anchor. It signs only the intermediate CA’s certificate.
  2. Intermediate CA: the CA that signs certificates for individual servers and services.
                      Root CA
                         │
                         │ signs
                         ▼
                  Intermediate CA
                         │
                         │ issues certificates
                         │
             ┌───────────┼───────────┐
             │           │           │
             ▼           ▼           ▼
          Proxmox     Proxmox3     Sophos

Clients only need to trust the root CA certificate. The intermediate CA does the day-to-day signing, which brings a few benefits:

  • One trust anchor: Import one certificate into your clients, and every certificate issued below it validates.
  • Root key stays out of daily use: Routine issuance doesn’t touch the root CA’s private key.
  • Replaceable intermediate: If the intermediate CA is compromised, you can replace it without replacing the root and redistributing it to every client.
  • Consistent management: New services get a certificate from the same place instead of yet another self-signed one.

⚠️ Warning: Right now, the root CA and the intermediate CA live in the same LXC container, and both private keys are on the same filesystem. That is convenient, but it defeats much of the point of a root CA, which should stay offline and be used only to sign or renew the intermediate CA’s certificate. My mid-term plan is to move the intermediate CA into its own permanently running container and leave the root CA container powered off.

The MicroCA server

Everything lives under /pki on ct-microca:

/pki
├── ca
│   ├── root
│   └── intermediate
├── public
└── requests
    ├── proxmox
    ├── proxmox3.mgmt.manzana.home
    └── sophos
DirectoryResponsibility
/pki/ca/rootRoot CA identity, private key, configuration, and certificate database
/pki/ca/intermediateCertificate issuance, signing operations, and certificate history
/pki/publicPublic CA certificates and trust-chain files for distribution
/pki/requestsPer-host certificate requests and related files

This keeps the management of the CAs apart from the management of individual host certificates.

The root CA

/pki/ca/root/
├── certs/
│   └── root.cert.pem
├── crl/
├── newcerts/
│   └── 1000.pem
├── private/
│   └── root.key.pem
├── index.txt
├── index.txt.attr
├── openssl-root.cnf
├── serial
└── serial.old

root.cert.pem is the public root certificate. Unlike a server certificate, it is self-signed, so nothing vouches for it except the fact that you install it into your trust stores yourself. That is the step that makes everything below it trusted.

root.key.pem is the most sensitive file in the whole PKI. It signs the certificates of subordinate CAs, and anyone holding it can mint certificates that all your clients will accept. It is readable only by the root user:

-r-------- root.key.pem

The index.txt file is OpenSSL’s certificate database. The root CA’s newcerts directory holds a single archived certificate, 1000.pem. That fits a root CA that has so far signed only one intermediate certificate, though I haven’t inspected the certificate to confirm it.

The intermediate CA

/pki/ca/intermediate/
├── certs/
│   ├── intermediate.cert.pem
│   ├── proxmox.crt
│   └── proxmx3.crt
├── crl/
├── csr/
│   ├── intermediate.csr.pem
│   ├── proxmox.csr
│   └── proxmox3.csr
├── newcerts/
│   ├── 1000.pem
│   ├── 1001.pem
│   ├── 1002.pem
│   ├── 1002.fullchain.pem
│   ├── 1003.pem
│   └── 1003.fullchain.pem
├── private/
│   └── intermediate.key.pem
├── openssl-intermediate.cnf
├── index.txt
├── serial
└── crlnumber

Yes, proxmx3.crt is spelled that way on disk. It’s a good example of why naming conventions are on my improvement list.

intermediate.cert.pem is signed by the root CA, which is what creates the chain of trust:

Trusted Root CA
    │
    └── Intermediate CA
            │
            └── Server Certificate

When a certificate is needed, the intermediate CA takes a certificate signing request (CSR), signs it according to its OpenSSL configuration and issuance policy, assigns a serial number, and records the result in its database.

The serial-numbered files in newcerts are the archived certificates this CA has issued. The history looks like this:

DateCertificatePurpose
February 11, 20261000.pemSophos
February 19, 20261001.pemInitial Proxmox certificate
March 6, 20261002.pemProxmox3
March 7, 20261003.pemUpdated Proxmox certificate

The index.txt database records each certificate’s serial number, subject, expiration date, and revocation status. Include it in every backup of the CA, because the CA can’t track its own lifecycle without it.

Per-host certificate files

Host-specific files live under /pki/requests.

Proxmox

/pki/requests/proxmox/
├── proxmox.key
├── proxmox.csr
├── proxmox.csr.pem
├── proxmox.cert.pem
├── proxmox.fullchain.pem
└── proxmox.san.cnf
FilePurpose
proxmox.keyPrivate key for the server
proxmox.csrCertificate signing request
proxmox.cert.pemIssued server certificate
proxmox.fullchain.pemCertificate bundled with its issuing CA chain
proxmox.san.cnfSubject Alternative Name configuration

The SAN configuration matters most here. Modern TLS clients match the DNS name or IP address you typed against the certificate’s Subject Alternative Name extension, not the common name. If the name isn’t listed there, the browser rejects the certificate even though the chain is valid.

Proxmox3

The second Proxmox host uses a directory named after its management DNS name:

/pki/requests/proxmox3.mgmt.manzana.home/
├── proxmox3.key
├── proxmox3.csr
├── proxmox3.del.csr
├── proxmox3.crt
├── proxmox3.fullchain.pem
└── proxmox3.san.cnf

Sophos

/pki/requests/sophos/
├── sophos.cert.pem
└── sophos.csr

There is no private key here. I generated the key on the Sophos firewall and exported only the CSR to the MicroCA for signing. That is the better arrangement, since the firewall’s private key never has to leave the device.

Certificate chains

A certificate from a private CA isn’t trusted automatically. The client has to build a valid path from the server certificate up to a root it trusts.

The MicroCA publishes three files for that purpose:

/pki/public/
├── root-ca.pem
├── intermediate-ca.pem
└── ca-chain.pem
FilePurpose
root-ca.pemPublic root CA certificate
intermediate-ca.pemPublic intermediate CA certificate
ca-chain.pemCombined CA certificate bundle

When a browser opens the Proxmox web interface:

  1. It establishes a TLS connection.
  2. Proxmox presents its server certificate and, ideally, the intermediate CA certificate.
  3. The browser verifies the signatures and certificate constraints.
  4. The chain ends at the root CA that is installed in the client’s trust store.
  5. The browser also checks the validity dates and the requested hostname.

A full-chain file for a server contains the server certificate followed by the intermediate:

-----BEGIN CERTIFICATE-----
Server Certificate
-----END CERTIFICATE-----

-----BEGIN CERTIFICATE-----
Intermediate CA Certificate
-----END CERTIFICATE-----

The root certificate is not part of it. It is distributed separately through the clients’ trust stores.

Issuing a certificate

The workflow follows the standard OpenSSL model. The commands below are representative; the exact options depend on your CA configuration.

1. Generate a private key

openssl genpkey \
  -algorithm RSA \
  -pkeyopt rsa_keygen_bits:3072 \
  -out proxmox.key

If the target system can generate its own key, do it there, as with the Sophos firewall.

2. Create a CSR

openssl req \
  -new \
  -key proxmox.key \
  -out proxmox.csr \
  -config proxmox.san.cnf

The CSR contains the public key and the requested identity, including the SANs from the configuration file. It doesn’t contain the private key.

3. Sign the CSR with the intermediate CA

openssl ca \
  -config /pki/ca/intermediate/openssl-intermediate.cnf \
  -in proxmox.csr \
  -out proxmox.crt

What the certificate ends up containing depends on the extensions and policy in openssl-intermediate.cnf and on how the CA validates the requested names. Check the result before deploying it.

4. Build the full chain

cat proxmox.crt \
    /pki/public/intermediate-ca.pem \
    > proxmox.fullchain.pem

Use this file wherever the target service expects the certificate together with its chain.

5. Deploy and verify

Install the certificate and private key on the target host; the exact steps depend on the platform. Afterwards, verify the trust path, the validity period, the intended purpose, and the hostname.

Revocation

A PKI also has to handle renewal, replacement, and revocation. Both CAs have a crl directory, and the intermediate CA has a crlnumber file, so the OpenSSL mechanics are in place. But both crl directories are empty. I haven’t implemented CRL publishing yet.

A working revocation process would:

  1. Mark the certificate as revoked in the issuing CA’s database.
  2. Generate a signed CRL.
  3. Publish the CRL where clients can fetch it.
  4. Make sure clients actually check it.

Until then, a revoked certificate stays acceptable to clients until it expires.

Protecting the keys and the CA

All private keys are restricted to their owner:

root.key.pem          0400
intermediate.key.pem  0400
proxmox.key           0600
proxmox3.key          0600

That is a sensible baseline, but it is only a baseline. Encrypting CA keys at rest and protecting backups would add real protection. The bigger issue is the one from the warning above: with both CA keys on one instance, compromising the container compromises the whole hierarchy.

For backups, the CA is one operational unit. Back up:

  • The root and intermediate private keys
  • The CA certificates
  • The OpenSSL configuration files
  • The certificate databases (index.txt)
  • The serial number and CRL number state
  • The archived issued certificates

Public certificates alone are not enough to recover the CA. Backups that contain private keys must be encrypted and tightly controlled.

What I want to improve

  • Offline root CA: Separate the root key from the operational intermediate CA, as described above.
  • Revocation: Publish CRLs and make sure clients check them.
  • Automated renewal: Find a repeatable mechanism, possibly ACME with a suitable CA service or automation layer.
  • Certificate inventory: Track subjects, SANs, expiry dates, owners, and deployment targets in one place.
  • Monitoring: Get a warning before a certificate expires and a service breaks.
  • Consistent naming: Settle on one convention for CSRs, certificates, keys, and full-chain files. Yes, proxmx3.crt included.
  • Keys generated on the target: Do this wherever the target system supports it.

The next steps aren’t about issuing more certificates. They’re about the processes around the CA: key protection, lifecycle management, revocation, monitoring, and recovery. With those in place, the MicroCA can grow from a manually administered setup into something I can rely on for the long term.