TLS certificates¶
bxp-cli tls gets a TLS certificate. It does three things:
- It creates a new private key on your machine.
- It asks the CA for a certificate for that key.
- It writes the key and the certificate to two files, named after the certificate.
| File | What it is |
|---|---|
<name>.key |
The private key. It never leaves your machine. |
<name>.crt |
The certificate, followed by the certificate of the intermediate CA that issued it. |
The files are written to the current folder, or to the folder you give with
--out-dir.
Run bxp-cli trust before you use bxp-cli tls.
A server certificate¶
To get a certificate for a server, you need a one-time token with the
purpose HOST-CERTIFICATE. A BastionXP administrator creates the token in
the web portal: they open the authority in Authority Manager and choose
Create token under One-time tokens. The token is valid for 10
minutes.
$ bxp-cli tls --token $TOKEN --name web1.example.com
Private key: web1.example.com.key
Certificate: web1.example.com.crt
Valid until: 2027-02-17 14:37 UTC
--name is the server's name. It becomes the certificate's common name, and
also its DNS name. Give exactly one --name.
The certificate can be used both as a TLS server certificate and as a TLS client certificate. So the server can also use it to connect to other services that require mutual TLS.
$ openssl x509 -in web1.example.com.crt -noout -subject -issuer -ext subjectAltName,extendedKeyUsage
subject=O=Example Inc, CN=web1.example.com
issuer=CN=My CA Intermediate CA
X509v3 Extended Key Usage:
TLS Web Server Authentication, TLS Web Client Authentication
X509v3 Subject Alternative Name:
DNS:web1.example.com
A client certificate for yourself¶
To get a client certificate in your own name, run bxp-cli tls without a token.
Your browser opens, and you log in with your company's SSO account:
$ bxp-cli tls
Log in in your browser. If it does not open, go to:
http://127.0.0.1:53817/login
Private key: [email protected]
Certificate: [email protected]
Valid until: 2026-11-19 22:37 UTC
Roles: admins
This login works only if the authority has an OIDC verifier for your SSO provider. See OIDC SSO.
On a machine without a browser¶
On a machine without a browser, such as a server you reach with SSH, add
--no-browser. bxp-cli then prints the login address instead of opening it:
The address points to the machine that bxp-cli runs on, not to your own
computer. So, from your computer, first forward that port with
ssh -L 53817:127.0.0.1:53817 <the machine>. Then open the address in your
browser.
With a token instead of a login¶
Instead of logging in, you can give a token with the purpose
USER-CERTIFICATE. An admin creates it in the portal with Create token.
This is useful in scripts:
Client certificates are valid for a short time: 8 hours by default.
Flags¶
| Flag | What it means |
|---|---|
--token |
A one-time token. You can also set it with BXP_CLI_TOKEN. Without a token, you log in in your browser. |
--name |
The server's name, for a server certificate. |
--out-dir |
The folder to write the key and the certificate to. The default is the current folder. |
--force |
Replace the key and certificate files if they already exist. |
--key-type |
The type of the new key: ecdsa (the default) or rsa. |
--encrypt-key |
Encrypt the private key with a passphrase. bxp-cli asks you for the passphrase. |
--no-browser |
Print the login address instead of opening the browser. |
If you have not run bxp-cli trust, also give --ca-url, --authority and
--root. See Configuration.
Use the certificate¶
The .crt file contains the certificate followed by the intermediate CA's
certificate. This is the format that web servers expect:
A client trusts this certificate once it trusts the CA's root certificate.
bxp-cli trust saved the root certificate as ~/.bxp-cli/tls_root_ca.crt:
For certificates that renew themselves automatically, use ACME.