Log inSign up

Make your own TLS certificates with OpenSSL

For a quick test, one OpenSSL command creates a key and a self-signed certificate with the right subject alternative names. For several internal services, create a private certificate authority once, add its root certificate to the trust store of your own machines, and sign a certificate for each service. Clients that trust your root then connect without warnings, while public sites should still use a free public certificate.

Topic: Security · Tested on: Ubuntu 24.04 and 22.04, Debian 12 and 13, Rocky Linux 9, AlmaLinux 9 · Updated 2026-12-03

When is a self-signed certificate the right choice?

Use one when the service is not meant for the general public: an admin panel reached over a VPN, a database or message broker that needs TLS between your own servers, a lab, or a box with no domain name yet. Browsers and tools cannot verify who issued it, so visitors would see a warning. For anything public with a domain name, a free certificate from Certbot and Let's Encrypt is simpler and trusted everywhere.

A private CA sits in the middle. You create one root certificate, install it on the devices you control, and from then on every certificate it signs is trusted by those devices.

How do I check OpenSSL?

OpenSSL is part of every image we offer. Confirm the version and that the command line tool is present:

openssl version
# if missing on a minimal install
sudo apt install openssl      # Ubuntu, Debian
sudo dnf install openssl      # Rocky, Alma

Ubuntu 24.04, Debian 12 and 13, Rocky 9 and Alma 9 all ship OpenSSL 3, which supports the -addext option used below. Work in a private folder: mkdir -p ~/pki && chmod 700 ~/pki && cd ~/pki.

How do I create a self-signed certificate in one command?

Generate an elliptic curve key and a certificate valid for a year, listing every name and IP the clients will use in the subject alternative name. Modern clients ignore the common name, so the SAN line matters:

openssl req -x509 -newkey ec -pkeyopt ec_paramgen_curve:prime256v1 -nodes -days 365 -keyout app.key -out app.crt -subj "/CN=app.example.net" -addext "subjectAltName=DNS:app.example.net,IP:198.51.100.24"
openssl x509 -in app.crt -noout -subject -dates -ext subjectAltName

-nodes leaves the key unencrypted so a service can start without a passphrase; OpenSSL 3 also accepts the newer spelling -noenc. Protect the key with file permissions instead: chmod 600 app.key.

How do I build a small private CA?

Create a root key and a long lived root certificate marked as a CA. Keep this key offline or at least on a machine that runs nothing else:

openssl req -x509 -newkey ec -pkeyopt ec_paramgen_curve:prime256v1 -days 3650 -keyout ca.key -out ca.crt -subj "/CN=Example Internal Root CA" -addext "basicConstraints=critical,CA:TRUE" -addext "keyUsage=critical,keyCertSign,cRLSign"
chmod 600 ca.key

Without -nodes, OpenSSL asks for a passphrase for the CA key, which is what you want. Store that passphrase in your password manager. Anyone who gets the CA key and passphrase can create certificates your devices will trust, so guard it accordingly.

How do I issue a server certificate from the CA?

Create a key and a signing request for the service, then sign it with the CA and add the extensions a server certificate needs:

openssl req -new -newkey ec -pkeyopt ec_paramgen_curve:prime256v1 -nodes -keyout db1.key -out db1.csr -subj "/CN=db1.example.net"
cat > db1.ext <<EOF
basicConstraints=CA:FALSE
keyUsage=critical,digitalSignature
extendedKeyUsage=serverAuth
subjectAltName=DNS:db1.example.net,IP:198.51.100.24
EOF
openssl x509 -req -in db1.csr -CA ca.crt -CAkey ca.key -CAcreateserial -days 397 -sha256 -extfile db1.ext -out db1.crt
openssl verify -CAfile ca.crt db1.crt

The final command prints db1.crt: OK. A validity of about 13 months keeps you in step with browser limits for certificates they accept. Repeat the step for each service, changing the names.

How do I make Linux clients trust my CA?

Copy only ca.crt, never the key, into the system trust store of each client and refresh it. On Ubuntu and Debian the file must end in .crt:

sudo cp ca.crt /usr/local/share/ca-certificates/example-internal-ca.crt
sudo update-ca-certificates

On Rocky Linux and AlmaLinux:

sudo cp ca.crt /etc/pki/ca-trust/source/anchors/example-internal-ca.crt
sudo update-ca-trust

Tools that use the system store, such as curl, wget, Python requests and most language runtimes, now accept your certificates. Firefox keeps its own store unless enterprise policy says otherwise, so import the root there under certificate settings. On a workstation, add it to the operating system keychain.

How do I use the certificate in Nginx?

Copy the files to a fixed location with tight permissions and reference them in the server block:

sudo install -d -m 700 /etc/ssl/private-internal
sudo install -m 600 db1.key /etc/ssl/private-internal/
sudo install -m 644 db1.crt /etc/ssl/private-internal/

server {
    listen 443 ssl;
    listen [::]:443 ssl;
    server_name db1.example.net;
    ssl_certificate     /etc/ssl/private-internal/db1.crt;
    ssl_certificate_key /etc/ssl/private-internal/db1.key;
}

Reload with sudo nginx -t && sudo systemctl reload nginx, then test from a client that trusts the CA:

curl -v https://db1.example.net/
curl --cacert ca.crt https://db1.example.net/

The second form works even on machines where you did not install the root. The Nginx guide covers the rest of the server block.

How do I renew or revoke private certificates?

Renewal is simply issuing a new certificate from a fresh request before the old one expires; put the expiry date in your calendar or check it with openssl x509 -enddate -noout -in db1.crt. Revocation needs a certificate revocation list, which many clients never check, so for a small setup the practical answer is short lifetimes and replacing the CA if its key leaks. If you manage dozens of services, a dedicated private CA server such as step-ca automates issuing and renewal with the ACME protocol.

Plans that fit this guide

Base city prices. Every plan includes a dedicated IPv4 address, IPv6, full root and all 18 images.

All prices
PlanFits becauseSizeMonthlyOrder from
A1-1creating certificates needs almost no resources1 vCPU, 1 GB RAM, 25 GB NVMe$3.60/mo$43.20 for 12 months

Questions about Self-signed certificates and a private CA

Why does my browser still warn about my self-signed certificate?

The browser does not trust the issuer, or the name you typed is missing from the subject alternative name list. Install your CA root on that device and check the SAN entries.

Can I use a self-signed certificate for a public website?

It works technically, but every visitor sees a warning. Use a free public certificate from Certbot for public sites.

Should I use RSA or ECDSA keys?

ECDSA P-256 keys are small, fast and widely supported. Use RSA 3072 or larger only if an old client cannot handle ECDSA.

How long should my root CA be valid?

Ten years is common for a private root because replacing it means touching every client. Keep server certificates short, around a year.

Is the internal CA useful over a VPN?

Yes. Services reached only through WireGuard can still use TLS with names your own DNS resolves.