Skip to content

Getting Started

BastionXP TLS X.509 Certificate Manager

Follow the steps below to download, install and run BastionXP as an TLS X.509 Certificate Manager in your self-hosted server on-prem.

Prerequisites

You need to have the following to install and run BastionXP Certificate Manager: - A Linux VM or server (Debain or RHEL or Any Linux distribution) - TCP Port: 443

BastionXP PKI/CA VM Setup

Step 1.1 - Download and Install

On the Linux VM, follow the instructions here to download and install the appropriate BastionXP binary package for your Linux distro as RPM or Debian package.

BastionXP will be installed as a Linux Systemd service. It runs as root, and keeps its data in /var/lib/bastionxp.

Step 1.2 - The Server's Certificate

BastionXP serves its web portal and its API over HTTPS. For this, it needs a certificate and a private key, which you provide. BastionXP never creates its own HTTPS certificate.

Put the certificate and its private key in BastionXP's data directory, with these names:

/var/lib/bastionxp/server.crt
/var/lib/bastionxp/server.key

In production, the certificate must be for BastionXP's domain name, for example ca.example.com. You can get it from your company's PKI or from a public CA. Or BastionXP can get one from Let's Encrypt by itself. See Configuration.

This guide runs BastionXP on localhost. So create a self-signed certificate for localhost, and make this machine trust it:

sudo openssl req -x509 -newkey ec -pkeyopt ec_paramgen_curve:P-256 -nodes -days 365 \
    -subj /CN=localhost -addext subjectAltName=DNS:localhost \
    -keyout /var/lib/bastionxp/server.key -out /var/lib/bastionxp/server.crt
sudo chmod 600 /var/lib/bastionxp/server.key
sudo cp /var/lib/bastionxp/server.crt /usr/local/share/ca-certificates/bastionxp-localhost.crt
sudo update-ca-certificates

Step 1.3 - The Key-Encryption Key

BastionXP keeps the private keys of its CAs in its database, and it encrypts them there. The key that encrypts them is called the key-encryption key (KEK). The KEK is kept in a file outside the database.

Create the KEK once:

$ sudo mkdir -p /etc/bastionxp
$ sudo bastionxp kek create --out /etc/bastionxp/kek
KEK:     /etc/bastionxp/kek
KEK id:  90e1fbc8cfcbe55a

Back it up now, separately from the database: in a password manager or a
safe, never next to the database backups. Losing the KEK means losing every
certificate authority. Every BastionXP server needs the same KEK.

See Key protection for more.

Step 1.4 - Configuration File

Create a configuration file named config.yaml in the /etc/bastionxp directory, with the following contents.

email: [email protected]
domain: localhost
org_name: Example Corporation
kek_file: /etc/bastionxp/kek
  • email is the email address of the web portal's first administrator.
  • domain is the DNS name of your BastionXP server.
  • org_name is the name of your organization. BastionXP writes it into the certificates that it issues.
  • kek_file is the path of the KEK that you created in step 1.3.

See Configuration for all the settings.

Step 1.5 - Restart

The package starts BastionXP when you install it. At that time, there was no configuration file yet, so BastionXP could not start. Restart it now, so that it reads the configuration file.

sudo systemctl restart bastionxp

BastionXP writes its log to the system journal. Read it with:

sudo journalctl -u bastionxp --no-pager -n 20

You will see log lines like these. This is a shortened example.

level=INFO msg="key-encryption key loaded" kek_id=90e1fbc8cfcbe55a
level=INFO msg="primary admin created" [email protected]
level=WARN msg="the primary admin has no password yet: open this link to set it, and a second factor" [email protected] link="https://localhost/#/setup?token=0xKz30j3DjUeEUyEYOgWPzIzaztkhpCPh-02HfC2V0A" expires=2026-11-29T06:14:27Z
level=INFO msg="server started" address=:443 authorities=[]

The line with link= is important. It is the one-time link that you use in the next step to set up the administrator account.

If BastionXP does not start, the log tells you why. For example, the message may say that server.crt or the KEK is missing, or that a setting in config.yaml is misspelled.

Step 1.6 - Set up the Administrator Account

The first administrator has no default password. Instead, you use the one-time setup link from the log.

The setup page: choose a password

  1. Open the setup link in your browser. The link works once, and it is valid for 24 hours.

    If the link has expired, or if you cannot find it, make a new one with this command:

    sudo bastionxp admin setup-link --config /etc/bastionxp/config.yaml
    
  2. Choose a password. It must have at least 12 characters, and it must not be your email address or a password from a list of leaked passwords.

  3. Set up a second factor. The portal asks every administrator for one. Scan the QR code with an authenticator app, such as Google Authenticator, Microsoft Authenticator or 1Password, and type the 6-digit code that the app shows. You can use a passkey instead.

  4. Save the ten recovery codes that the portal shows, in your password manager. Each code works once, if you ever lose your authenticator app. The portal shows them only now.

You are now signed in to the web portal. See Sign in and set up your account for more about passwords, second factors and recovery codes.

Step 1.7 - Create the Root CA and an Authority

In the web portal:

  1. In the sidebar, choose Authority Manager. Under Root CAs, on the ECDSA root CA card, choose Create ECDSA root CA, and confirm.

    You create the root CA only once. It signs the intermediate CA of every authority that you add later.

    The card now shows the root CA's SHA-256 fingerprint. Copy it with the button next to it. You need it in step 2.2.

  2. Choose Add authority, and fill in:

    • Name: My CA. The Authority ID becomes my-ca.
    • Select authority type: Certificate Authority.
    • Allow one-time tokens and SSO login: leave it ticked. It is ticked by default.

    Leave the other options as they are. You can change them later on the authority's page.

    The Add an authority dialog

  3. Choose Add authority.

The TLS X.509 Certificate Manager is now ready. For all the options of an authority, see Certificate authorities.

Get a Server Certificate

To get a server certificate from the CA, we need to use the BastionXP client utility: bxp-cli

Step 2.1 - Download BastionXP client

Follow the instructions here to download and install BastionXP Client bxp-cli in your machine.

Step 2.2 - Establish Trust with the Certificate Manager

Before you can get TLS certificates from the CA, the bxp-cli client must trust the BastionXP certificate authority. bxp-cli trust sets this up.

bxp-cli trust needs two values:

  • the authority's ID, my-ca;
  • the root CA's SHA-256 fingerprint, which you copied in step 1.7, from the root CA's card in Authority Manager.

Now make the client trust the CA:

$ bxp-cli trust --ca-url https://localhost --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://localhost
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.

bxp-cli trust fetches the root CA's certificate from the server. It accepts the certificate only if its fingerprint matches the one you gave.

Then it saves two files in the .bxp-cli folder in your home directory. tls_root_ca.crt is the root certificate. config.json holds the server's address and the authority's ID.

$ ls ~/.bxp-cli
config.json  tls_root_ca.crt

bxp-cli trust makes only bxp-cli trust the CA. If you also want other programs on this machine to trust it, add the root CA's certificate to the system trust store. On Debian and Ubuntu, run:

sudo cp ~/.bxp-cli/tls_root_ca.crt /usr/local/share/ca-certificates/bastionxp-ca.crt
sudo update-ca-certificates

After this, programs on this machine trust every certificate that the BastionXP CA issues. For other operating systems, see Trust the CA.

Step 2.3 - Get the Server Certificate

To get a server certificate, you need a one-time token. Create it in the web portal:

  1. Open Authority Manager, and then the authority my-ca.
  2. Under One-time tokens, choose Create token, and select the purpose HOST-CERTIFICATE.

The token is valid for 10 minutes.

Now, get a signed server certificate for localhost from the CA:

$ bxp-cli tls --token [HOST-CERTIFICATE token] --name localhost
Private key:  localhost.key
Certificate:  localhost.crt
Valid until:  2027-02-17 14:37 UTC

bxp-cli tls creates the private key on your machine. It never sends the private key to the CA. It writes the key and the certificate to the current directory, in files named after the server. To write them to another directory, use --out-dir.

$ ls
localhost.crt  localhost.key

localhost.crt contains the server certificate, followed by the intermediate CA's certificate. This is the format that web servers expect.

Get a Client Certificate

Step 3.1 - Get the Client Certificate

You also use bxp-cli to get a client certificate. First, create a token in the web portal, as in step 2.3, but with the purpose USER-CERTIFICATE. Then run:

$ bxp-cli tls --token [USER-CERTIFICATE token]
Private key:  [email protected]
Certificate:  [email protected]
Valid until:  2026-11-19 22:37 UTC

The client certificate is issued in your name, [email protected]. It is valid for 8 hours.

You can also get a client certificate without a token, by logging in with your SSO account. For this, set up OIDC SSO. Then bxp-cli tls without a token opens your browser, and you log in there.

For all the options of bxp-cli tls, see TLS certificates.

View the Issued Certificates:

We'll use the OpenSSL tool to verify the certificates generated so far.

Root CA Certificate:

$ openssl x509 -in ~/.bxp-cli/tls_root_ca.crt -noout -subject -issuer -dates -ext basicConstraints
subject=CN=BastionXP Root CA
issuer=CN=BastionXP Root CA
notBefore=Nov 28 06:22:33 2026 GMT
notAfter=Nov 25 06:22:33 2036 GMT
X509v3 Basic Constraints: critical
    CA:TRUE

Server Certificate:

$ openssl x509 -in localhost.crt -noout -subject -issuer -dates -ext subjectAltName,extendedKeyUsage
subject=CN=localhost
issuer=CN=My CA Intermediate CA
notBefore=Nov 19 09:06:03 2026 GMT
notAfter=Feb 17 09:07:03 2027 GMT
X509v3 Extended Key Usage:
    TLS Web Server Authentication, TLS Web Client Authentication
X509v3 Subject Alternative Name:
    DNS:localhost

The authority's intermediate CA issued the server certificate. The root CA issued the intermediate CA. To check this chain, run:

$ openssl verify -CAfile ~/.bxp-cli/tls_root_ca.crt -untrusted localhost.crt localhost.crt
localhost.crt: OK

Client Certificate:

$ openssl x509 -in [email protected] -noout -subject -issuer -dates -ext subjectAltName,extendedKeyUsage
subject=CN=[email protected]
issuer=CN=My CA Intermediate CA
notBefore=Nov 19 09:06:03 2026 GMT
notAfter=Nov 19 17:07:03 2026 GMT
X509v3 Extended Key Usage:
    TLS Web Client Authentication
X509v3 Subject Alternative Name:
    email:[email protected], URI:urn:user:[email protected]

Golang based TLS Server Example

We'll use the below hello world HTTPS web server written in Golang to test the server certificate issued by the BastionXP certificate authority.

package main
import (
    "net/http"
    "log"
)
var (
    CertFilePath = "localhost.crt"
    KeyFilePath  = "localhost.key"
)
func helloHandler(w http.ResponseWriter, req *http.Request) {
    w.Write([]byte("Hello, world!\n"))
}
func main() {
    http.HandleFunc("/hello", helloHandler)
    err := http.ListenAndServeTLS(":8443", CertFilePath, KeyFilePath, nil)
    if err != nil {
        log.Fatal(err)
    }
}
Execute the above Go program using the following command:

go run https_server.go &
Now, try connecting to the above HTTPS server using the following command:

curl https://localhost:8443/hello

You'll see the following error when you run the above command.

curl: (60) SSL certificate problem: unable to get local issuer certificate
More details here: https://curl.se/docs/sslcerts.html

curl failed to verify the legitimacy of the server and therefore could not
establish a secure connection to it. To learn more about this situation and
how to fix it, please visit the web page mentioned above.

This is because the curl command line utility is not aware of the BastionXP Root CA and therefore doesn't trust the server certificate issued by the CA.

To make the curl utility trust the BastionXP certificate authority and the certificates issued by it, use the --cacert flag in the curl command and provide the CA's root certificate as shown below:

$ curl --cacert ~/.bxp-cli/tls_root_ca.crt https://localhost:8443/hello

Hello, world!

Congratulations! You have successfully set up a private CA, generated a server certificate and used it for a HTTPS web service.

Next Steps

  • Try the Mutual TLS (mTLS) based HTTPS Web Server and HTTPS Client example using the TLS Server and Client certificates geneated above.
  • Configure BastionXP to issue server and client certificates after a successful OIDC SSO login based user authentication using Google, Microsoft, Okta, or Keycloak OIDC SSO.
  • Configure BastionXP to run on a private or public domain name (Eg: bastionxp.example.com).