Skip to content

Trust the CA

A client must know that it talks to the right CA. The administrator hands out two things:

  1. the CA's address, e.g. https://ca.example.com:8443, and
  2. the fingerprint of its root certificate.

On the CA machine, bxp fingerprint shows it at any time; bxp init printed it, and bxp serve logs it at every start (root_fingerprint=...).

bxp trust

$ bxp trust --ca-url https://ca.example.com:8443 --fingerprint 17f87e8c87a58e38d44701b4b87c615de3b7b7ce5e5304296db11492b0e5270e
Trusted:      https://ca.example.com:8443
Root:         Example Root CA
SHA-256:      17f87e8c87a58e38d44701b4b87c615de3b7b7ce5e5304296db11492b0e5270e
Saved in:     /home/alice/.config/bastionxp-ca

The bxp commands use this from now on. Other programs on this machine
do not; to make the whole system trust the CA, run:
  sudo cp /home/alice/.config/bastionxp-ca/root.crt /usr/local/share/ca-certificates/bastionxp-ca.crt && sudo update-ca-certificates

It:

  1. fetches the root certificate from the server,
  2. refuses it unless its fingerprint is the one given,
  3. connects again trusting only that root, so a server that merely hands out a copy of the public root is refused, and
  4. saves the address and the root.

From then on, the other client commands need neither an address nor a root file.

Flag Meaning
--ca-url The CA's address (or BXP_CA_URL).
--fingerprint The root certificate's SHA-256 fingerprint, from the administrator.
--ssh Also add the CA's SSH host key to known_hosts, so ssh trusts hosts with its certificates.
--known-hosts <file> The known_hosts file for --ssh (default ~/.ssh/known_hosts).
--force Replace the trust saved for another CA.

Hand out the fingerprint out of band

Give the fingerprint to people some other way than the CA server itself: a message, a wiki page, your configuration management. A fingerprint fetched from the same server would prove nothing, which is why the server offers no address for it. It is not a secret: anybody may see it.

Where the trust is saved

System Directory
Linux ~/.config/bastionxp-ca/ (or $XDG_CONFIG_HOME/bastionxp-ca/)
macOS ~/Library/Application Support/bastionxp-ca/
Windows %AppData%\bastionxp-ca\

It holds client.yaml (the address and the fingerprint) and root.crt. The trust belongs to the user who ran bxp trust: run it as root for renewals that run as root.

SSH host trust: --ssh

bxp trust --ca-url https://ca.example.com:8443 --fingerprint <fp> --ssh

adds an @cert-authority line for the CA's SSH host key to ~/.ssh/known_hosts, so ssh accepts servers with host certificates from this CA. See SSH host certificates.

The system trust store

bxp trust makes the BastionXP CA commands trust the CA. Browsers, curl and other programs use the system's trust store. The command prints how to add the root there, but does not do it itself: it needs admin rights and changes what every program on the machine trusts.

sudo cp root.crt /usr/local/share/ca-certificates/bastionxp-ca.crt
sudo update-ca-certificates
sudo cp root.crt /etc/pki/ca-trust/source/anchors/bastionxp-ca.crt
sudo update-ca-trust
sudo security add-trusted-cert -d -r trustRoot -k /Library/Keychains/System.keychain root.crt
certutil -addstore -f Root root.crt

Some programs keep their own trust store: Firefox (its certificate settings), Java (keytool -importcert -cacerts), Python requests (REQUESTS_CA_BUNDLE), Node.js (NODE_EXTRA_CA_CERTS).

Without bxp trust

Every client command also takes the address and the root each time, as flags or environment variables. See Client configuration.