Initialize the CA¶
bxp init creates the CA: the root, the intermediate, the SSH user and
host CA keys, and the token signing key. Run it once. It never
overwrites an existing CA.
Before you run it¶
Decide these first; they are written into the CA certificates and cannot be changed without new CA keys:
| Setting | Why it matters now |
|---|---|
ca.name |
The CA certificates are named after it: <name> Root CA, <name> Intermediate CA. Default BastionXP. |
ca.organization |
Written into the CA certificates and every issued certificate. Required. |
ca.key_type |
ecdsa (P-256, default) or rsa (3072 bits) for the CA keys. |
ca.name_constraints |
Written into the intermediate. Changing them later needs a new intermediate. See Name constraints. |
ca.root_validity |
The root's lifetime, 10y by default (1 to 30 years). Used only here, at init. See CA lifetimes. |
ca.intermediate_validity |
The intermediate's lifetime, 3y by default. Used at init and at every new-intermediate. |
data_dir |
Where everything is stored. |
A minimal configuration:
data_dir: /var/lib/bastionxp-ca
ca:
name: Example
organization: Example Org
Create it¶
The root key never touches data_dir. Keep a second copy elsewhere,
and its passphrase in a password manager.
The root key is written to data_dir/root.key. Move it offline
afterwards; the server warns while it is there.
Also encrypts the keys the server uses, and asks for their passphrase (unless one is configured). See Protect the CA keys.
init asks twice for the root key's passphrase, at least 12
characters. For scripts, --root-passphrase-file <file> reads it from a
file instead (/dev/stdin works).
Flags¶
| Flag | Meaning |
|---|---|
--root-key-out <file> |
Write the root key here, e.g. on removable storage, instead of into data_dir. |
--root-passphrase-file <file> |
Read the root key's passphrase from this file instead of asking. |
--encrypt-keys |
Encrypt the keys the server uses; asks for a passphrase if none is configured. |
--external-root |
Make no root: create everything else and a CSR for the intermediate, for an existing company CA to sign. See Under an existing root. |
What it writes¶
| File | What it is |
|---|---|
root.crt |
The root certificate (10 years by default). |
root.key |
The root key, always encrypted (unless --root-key-out). |
intermediate.crt, intermediate.key |
The intermediate CA (3 years by default). |
ssh_user_ca.key, ssh_user_ca.pub |
The SSH user CA. |
ssh_host_ca.key, ssh_host_ca.pub |
The SSH host CA. |
token.key |
Signs one-time tokens. |
Its output lists every file it wrote, in three groups: to hand out (public), to move offline (the root key), and kept by the server (secret, and whether they are encrypted). It ends with the command clients use to trust the CA, including the root certificate's fingerprint:
Clients trust this CA with:
bxp trust --ca-url <address of this server> --fingerprint 17f87e8c87a5...e5270e
Show the fingerprint again any time:
CA lifetimes¶
ca:
root_validity: 10y # the default; 1y to 30y
intermediate_validity: 3y # the default; 1y up to the root's lifetime
| Setting | Default | Range | Takes effect |
|---|---|---|---|
root_validity |
10y |
1 to 30 years | Once, at init. Changing it later does not change the root; bxp doctor says so. |
intermediate_validity |
3y |
1 year up to the root's lifetime | At init, and at every new-intermediate. |
- Units:
y(365 days) ord, e.g.1095d. - The intermediate can never outlive the root: the configuration
refuses an
intermediate_validitylonger thanroot_validity, andnew-intermediaterefuses to make one that would end after the root, saying how long it may be. - Under an existing root, the company's CA decides the
intermediate's lifetime, so
intermediate_validityis refused there.
Why these defaults: the root is the trust anchor, installed everywhere, and replacing it means a new CA, so it lives long and its key stays offline. The intermediate's key is online and signs every TLS certificate, so a shorter life limits what a stolen copy could do, and keeps replacing it a routine (public CAs replace theirs every few years too).
Running as a service user¶
On a production machine, run init as the user the server will run as,
so the files get the right owner:
sudo -u bastionxp-ca bxp init --config /etc/bastionxp-ca/bastionxp-ca.yaml --root-key-out /media/usb/root.key
See Run with systemd for the complete steps.