brewedbits.dev

Personal blog with guides and news on selfhosting, Linux and AI, from the Netherlands

nextDash nextdash --aboutYour bookmarks. Your terminal. checks your links knows your Docker host one container, no cloudLive demo →nextdash.cc ↗

Tip: openssl x509 -req signs a server certificate with your own CA

Openssl
~/tips/tip-openssl-x509-req-sign-ca

openssl x509 -req -in nas.csr \

Turn a CSR into a certificate signed by a homelab CA, keeping the host names from the request.

With your own CA you sign certificates for internal services yourself, and every device that trusts the CA trusts all of them. One openssl x509 command does the signing.

Assuming you have a CA certificate and key, and a CSR with the right Subject Alternative Names:

openssl x509 -req -in nas.csr \
  -CA ca.pem -CAkey ca.key -CAcreateserial \
  -days 365 -copy_extensions copy \
  -out nas.pem

-CAcreateserial creates a ca.srl file with a random serial number and keeps it next to the CA. -copy_extensions copy is the part people miss: without it, the SAN list from the request is dropped, and browsers reject the certificate for every name.

Check the result straight away:

openssl verify -CAfile ca.pem nas.pem
openssl x509 -in nas.pem -noout -ext subjectAltName

The first should print nas.pem: OK, the second the names you asked for.

-copy_extensions on x509 needs OpenSSL 3.0 or newer; older versions need an extensions file passed with -extfile. Copying blindly also copies anything a request asks for, including CA:TRUE, so only sign requests you made or checked. Keep ca.key offline or at least encrypted: whoever has it can make certificates your devices trust for any name. Apple devices refuse server certificates valid for longer than 825 days, so I’d stay well under that.

Further reading: OpenSSL: openssl-x509, OpenSSL: openssl-verify

Going deeper: Run degoog on Unraid as your own search page, compared with SearXNG and 4get

More Openssl tips openssl s_client -connect 203.0.113.10:443 -servername example.com </dev/null | openssl x509 -noout -subject openssl x509 -in cert.pem -days 365 -signkey key.pem -out cert-new.pem printf %s hello | openssl dgst -sha256 -hmac secret openssl pkcs12 -legacy -in old.pfx -nokeys echo 'aGVsbG8gd29ybGQ=' | openssl base64 -d All Openssl tips (34) All topics

Link