HTTPS and certificates
In this document:
- Generating self-signed certificates
- Deploying: 4 targets, 1 gateway, 6 mountpaths, AWS backend
- Accessing HTTPS-based cluster
- Testing with self-signed certificates
- Observability: TLS related alerts
- Updating and reloading X.509 certificates
- Switching cluster between HTTP and HTTPS
Generating self-signed certificates
Creating a self-signed certificate along with its private key and a Certificate Authority (CA) certificate using OpenSSL involves steps:
- First, we create a self-signed Certificate Authority (CA) certificate (
ca.crt). - Second, create a Certificate Signing Request (
server.csr). - Finally, based on the CSR and CA we create the server certs (
server.keyandserver.crt) - as follows:
Important: make sure to specify correct DNS. For local deployments,
localhostand127.0.0.1domain must be provided - otherwise certificate validation will fail.
Deploying: 4 targets, 1 gateway, 6 mountpaths, AWS backend
This is still a so-called local playground type deployment from scratch, whereby we are not trying to switch an existing cluster from HTTP to HTTPS, or vice versa. All we do here is deploying a brand new HTTPS-based aistore.
Note: If you need to switch an existing AIS cluster to HTTPS, please refer to these steps.
Notice environment variables above: AIS_USE_HTTPS, AIS_SKIP_VERIFY_CRT, AIS_SERVER_CRT and AIS_SERVER_KEY.
Also note that
<path-to-cert>(above) must not necessarily be absolute. Assuming, you haveserver.*certs in your local directory, the following will work as well:
Accessing HTTPS-based cluster
To use CLI, try first any command with HTTPS-based cluster endpoint, for instance:
But if it fails with “failed to verify certificate” message, perform a simple step to configufre CLI to skip HTTPS cert validation:
And then try again.
Testing with self-signed certificates
In the previous example, the cluster is simply ignoring SSL certificate verification due to AIS_SKIP_VERIFY_CRT being true. For a more secure setup, consider validating certificates by configuring the necessary environment variables as shown in the table below:
More info on
AIS_CLIENT_AUTH_TLS.
In the following example, we run https based deployment where AIS_SKIP_VERIFY_CRT is false.
Notice that when the cluster is first time deployed server.conf environment (above) overrides aistore cluster configuration.
Environment is ignored upon cluster restarts and upgrades.
On the other hand, ais/test/tls-env/client.conf contains environment variables to override CLI config. The correspondence between environment and config names is easy to see as well.
See also: Client-side TLS environment
Observability: TLS related alerts
HTTPS deployment implies (and requires) that each AIS node has a valid TLS (a.k.a. X.509) certificate.
The latter has a number of interesting properties ultimately intended to authenticate clients to the server (AIS node, in this case), and vice versa.
In addition, TLS certfificates tend to expire from time to time. In fact, each TLS certificate has expiration date with the standard-defined maximum being 13 months (397 days).
Some sources claim 398 days but the (much) larger point remains: TLS certificates do expire. Which means, they must be periodically updated and timely reloaded.
Starting v3.24, AIStore:
- tracks certificate expiration times;
- automatically - upon update - reloads updated certificates;
- raises associated alerts.
Associated alerts
Overall, there are currently 3 (three) alerts:
Updating and reloading X.509 certificates
Quoting WWW:
“The validity periods for digital certificates are determined by their accepting organizations …”, at https://www.sectigo.com/resource-library/how-long-are-digital-certificates-valid
Long story short, there is any number of reasons to update or replace X.509 certificate that AIStore uses to authenticate API calls.
But maybe the most common one is - expiration time. TLS certificates, also often referred to as X.509 certificates, do periodically expire. And the immediate implication is that the system must be able to (periodically) reload updated ones.
In AIStore, related functionality consists of two pieces:
- AIS nodes automatically reload updated certs while simultaneously adjusting the interval to check for the update.
- Separately, there’s an administrative API and CLI (shown below) to reload certificate.
The scope of this latter operation may be either a selected node or entire cluster.
As far as automatic adjustment of the polling interval, the resulting value depends on the remaining time (until expired) and works approximately as follows:
Upon initial loading, or every time when reloading, an AIS node logs a record that also shows the validity bounds, e.g.:
In addition, if certificate fails to load or expires, AIS node raises the namesake alert that - as usual - will show up in Grafana dashboard or via CLI show cluster, or both.
Overall, supported alerts include:
Finally, to view (existing) and/or reload (new) TLS certificates, see the following CLI reference:
When aistore is deployed with aithentication (enabled), the API (and CLI) to reload certificates will require administrative permissions.
See
ais config clustercommand and relatedauth.enabledknob.
Further references
Switching cluster between HTTP and HTTPS
From HTTP to HTTPS
This assumes that X.509 certificate already exists and the (HTTP-based) cluster is up and running. All we need to do at this point is switch it to HTTPS.
Goes without saying that localhost etc. are used here (and elsewhere) for purely illustrative purposes.
Instead of localhost, 127.0.0.1, port 8080, and the make command above one must use their respective correct endpoints and proper deployment operations.