Skip to content

Trust the CA

Before bxp-cli can get certificates, it must know that it is talking to the right certificate authority. bxp-cli trust sets this up. It is the first step on every machine.

bxp-cli trust needs three things, which the CA's administrator gives you:

  1. the address of the BastionXP server, for example https://ca.example.com,
  2. the ID of the certificate authority on that server, for example my-ca,
  3. the fingerprint of the root CA's certificate.

For the administrator: where to find the authority ID and the fingerprint

In the BastionXP web portal, open Authority Manager:

  • The ECDSA root CA card, under Root CAs, shows the root CA's SHA-256 fingerprint. Copy it with the button next to it.
  • The cards of the authorities show the ID of each authority, under its name.

Give the fingerprint to your users through a channel other than the BastionXP server itself. For example, send it in a message, put it on a wiki page, or distribute it with your configuration management. A fingerprint that users fetched from the same server would prove nothing, because a fake server could show a fake fingerprint.

The fingerprint is not a secret. Anybody may see it.

Run bxp-cli trust

$ bxp-cli trust --ca-url https://ca.example.com --authority my-ca \
    --fingerprint DE:E7:E7:C2:E2:64:AA:80:2A:5B:27:CA:A9:B0:F4:8D:60:2B:06:70:B8:CA:67:38:43:A1:52:B8:75:EC:8A:AC
Trusted:      https://ca.example.com
Authority:    my-ca
Root:         BastionXP Root CA
SHA-256:      dee7e7c2e264aa802a5b27caa9b0f48d602b0670b8ca673843a152b875ec8aac
Saved in:     /home/bob/.bxp-cli

The bxp-cli commands use this from now on.

This is what bxp-cli trust does:

  1. It fetches the authority's CA certificates from the server.
  2. It compares the root CA's fingerprint with the one you gave. If they differ, it refuses the certificates and saves nothing.
  3. It checks that the authority's other CA certificates were issued by that root CA.
  4. It saves the server's address, the authority's ID and the root CA's certificate in the .bxp-cli folder in your home directory.

After this, the other bxp-cli commands find the server, the authority and the root CA by themselves. You no longer need to give --ca-url, --authority or --root.

You can give the fingerprint the way openssl prints it, with colons and in upper case, or as plain hexadecimal.

Flag What it means
--ca-url The BastionXP server's address. You can also set it with the BXP_CLI_CA_URL environment variable.
--authority The certificate authority's ID. You can also set it with the BXP_CLI_AUTHORITY environment variable.
--fingerprint The root CA's SHA-256 fingerprint, from your administrator.
--force Replace the trust that is already saved for another CA.

How the server's own certificate is checked

During bxp-cli trust, the fingerprint is what proves that the root CA is the right one. So bxp-cli trust does not need to trust the server's own HTTPS certificate for this step.

Every later bxp-cli command checks the server's HTTPS certificate. It accepts a certificate that the machine already trusts, or one that the BastionXP root CA issued. The server's certificate normally comes from your company's PKI or a public CA, which managed machines already trust.

Trust is per user

bxp-cli trust saves the trust in the home directory of the user who runs it.

A command that you run with sudo runs as root, and uses root's home directory. On a machine where bxp-cli runs as root, run sudo bxp-cli trust ... too. This is the case, for example, when a timer runs sudo bxp-cli acme renew.

The system trust store

bxp-cli trust makes only bxp-cli trust the CA. Browsers, curl and other programs use the trust store of the operating system instead. If you want them to trust the certificates that the CA issues, add the root CA's certificate to the system trust store too:

sudo cp ~/.bxp-cli/tls_root_ca.crt /usr/local/share/ca-certificates/bastionxp-ca.crt
sudo update-ca-certificates
sudo cp ~/.bxp-cli/tls_root_ca.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 ~/.bxp-cli/tls_root_ca.crt
certutil -addstore -f Root tls_root_ca.crt

bxp-cli trust does not do this by itself. Adding a root CA to the system trust store needs admin rights, and it changes what every program on the machine trusts. That decision is yours.

Without bxp-cli trust

You can also skip bxp-cli trust. Then give the address, the authority's ID and the root CA's certificate to every command, as flags or as environment variables. See Configuration.

Errors

The message says What it means, and what to do
none of the server's CA certificates has this fingerprint: check it with the administrator Either the server is not the CA you were told about, or the fingerprint is wrong. Check both with your administrator.
the fingerprint must be a SHA-256 in hex (64 characters) The fingerprint is incomplete, or it is not a SHA-256 fingerprint. Ask your administrator for the SHA-256 fingerprint.
trust for another CA is saved already (...): use --force to replace it This user already trusts another CA. Add --force to replace that trust.
no server address: run "bxp-cli trust" first, or give --ca-url Run bxp-cli trust first. Or give --ca-url, --authority and --root to the command.