Transport Layer Security (TLS) is a protocol that uses cryptography to enable secure, tamper-proof communication over the network. This document describes the TLS functionality in Vespa and how to configure it. When properly configured, TLS ensures only trusted Vespa services can talk to each other. See accompanying reference for details on configuration syntax.
By default, all communication between self-hosted Vespa nodes is unauthenticated and unencrypted. This means anyone with network access can read and write data and potentially execute commands on the system. Enabling TLS is therefore a fundamental part of a secure Vespa installation.
You should configure TLS even if you already have a firewall set up to prevent outside connections to your system. TLS helps protect against the case even where an attacker has managed to get a foothold inside your private network. Vespa will in some future version require TLS for all internal communication. To ensure you are ready for this, secure your systems as soon as possible.
Vespa offers two separate planes of TLS connectivity:
This document only covers Vespa-internal communication.
Enabling TLS in Vespa means that all internal endpoints are mTLS protected, even HTTP servers for status pages and metrics. Be especially aware of this if you have custom solutions in place for collecting and aggregating low level metrics or status pages from the Vespa backends. Though the terms TLS and mTLS may be used interchangeably in this document, TLS implies mTLS for all Vespa-internal traffic.
Refer to the multinode-HA example application for a working example.
This section assumes you have some experience with generating and using certificates and private keys. For an introduction, see Appendix A: setting up with a self-signed Certificate Authority which gives step-by-step instructions on setting up certificates that can be used internally for a single Vespa application.
This feature is supported from Vespa 7.441.3.
In order to enable TLS, some extra files must be present on every node in your Vespa application:
How certificate and key material is distributed to the nodes is outside the scope of this article. See dedicated section for Vespa's support of automatic and live reloading of TLS credentials.
On any node running Vespa software, TLS is controlled via a single environment variable. This variable contains an absolute path pointing to a JSON configuration file:
This environment variable must be set to a valid file path before any Vespa services are started on the node. All nodes in your Vespa application must have a TLS config file pointing to the certificates that are trusted by the other nodes.
See Vespa environment variables for information on configuring environment variables for Vespa.
VESPA_TLS_CONFIG_FILE automatically enables TLS for all Vespa processes on the node.
Vespa command-line tools will automatically pick up the required configuration and work transparently.
The simplest possible configuration file only needs to know the certificates to trust and the certificate/key pair that identifies the node itself. Example:
Set the environment variable, for example by appending to conf/vespa/default-env.txt:
All file paths must be absolute. If a Vespa process cannot load one or more files, it will fail to start up.
For many simpler deployments, a dedicated self-signed Certificate Authority will be used for the Vespa cluster alone. In that case simply being in possession of a valid certificate is enough to be authorized to access the cluster nodes; no one except the Vespa nodes is expected to have such a certificate. More complex deployments may instead use a shared CA, e.g. a corporate CA issuing certificates to nodes across many services and departments. In that case simply having a valid certificate is not sufficient to be used as an authorization mechanism.
You can constrain which certificates may access the internal Vespa service by using authorization rules. These are consulted as part of every TLS handshake and must pass before any connection can be established.
Authorization rules are specified as part of the JSON configuration file using the top-level
Let's assume our Vespa cluster consists of many nodes, each with their own certificate signed by a shared Certificate Authority.
Each certificate contains a Subject Alternate Name (SAN) DNS name entry of the form
<unique-node-id>.mycluster.vespa.example.com, where unique-node-id is unique per cluster node.
These nodes will be running the actual Vespa services and must all be able to talk to each other.
Let's also assume there is a monitoring service that requires low-level access to the services.
Certificates presented by nodes belonging to this service will always have a Common Name (CN) value of
vespa-monitoring.example.com and a DNS SAN entry of the form
Any monitoring instance in any us-east region must be able to access our cluster, but no others.
Our TLS config file implementing these rules may look like this:
See the reference documentation for details on syntax and semantics.
Vespa performs periodic reloading of the specified TLS configuration file. Currently, this happens every 60 minutes. This reloading happens live and does not impact service availability. Both certificates, the private key and authorization rules are reloaded. Vespa currently does not watch the configuration file for changes, so altering the config file or any of its dependencies does not trigger a reload by itself.
If live reloading fails, the old configuration continues to be used and a warning is emitted to the local Vespa log.
Vespa does not currently lock files before reading them. To avoid race conditions where files are reloaded by Vespa while they are being written, consider splitting file refreshing into multiple phases:
With no Vespa services running on any nodes, ensure the
VESPA_TLS_CONFIG_FILE environment variable is set to
a valid configuration file path on every node,
and is visible to any Vespa start scripts.
Start Vespa services as you normally would. Check cluster health with
and check vespa-logfmt for any TLS-related error messages
that indicate a misconfiguration (such as certificate rejections etc.)—see the Troubleshooting section.
The cluster should quickly converge to an available state.
This is the simplest and fastest way to enable TLS, and is highly recommend if downtime is acceptable.
If you already have a Vespa application serving live traffic that you don't want to take down completely in order to enable TLS, it's possible to perform a gradual, rolling upgrade. Doing this requires insecure and TLS connections to be used alongside each other for some time, moving more and more nodes onto TLS. Finally, once all nodes are speaking only TLS, the support for insecure connections must be removed entirely.
To achieve this, Vespa supports a feature called insecure mixed mode. Enabling mixed mode lets all servers handle both TLS and insecure traffic at the same time.
Mixed mode is controlled via the value set in environment variable
TLS rollout happens in 3 phases:
Phase 1: clients do not use TLS, servers accept both TLS and plaintext clients
VESPA_TLS_CONFIGfile as documented in Configuring Vespa TLS.
Phase 2: clients use TLS, servers accept both TLS and plaintext clients
Phase 3: all clients and servers use TLS only
Successful configuration should be verified at runtime once TLS is enabled on all nodes.
The openssl s_client tool is suitable for this.
Connect to a Vespa service, e.g a configserver on port 19071 or a container on port 8080, and verify that
successfully completes the TLS handshake.
Further, you should verify that servers require clients to authenticate by omitting
-cert from above command.
s_client tool should print an error during handshake and exit immediately.
Vespa enables the HTTPS endpoint identification algorithm by default. This extra verification can only be used if all certificates have their respective host's IP addresses and hostnames in the Subject / Subject Alternative Names extensions. Disable hostname validation if this is not the case.
Our goal is to create cryptographic keys and certificates that can be used by Vespa for secure mTLS communication within a single Vespa installation.
This requires the following steps, which we'll go through below:
We'll be using the OpenSSL command-line tool to generate all our crypto keys and certificates.
When a server (or client) presents a certificate as part of proving its identity to us, we must have a way to determine if this information is trustworthy. We do this by verifying if the certificate is cryptographically signed by a Certificate Authority (CA) that we already know we can trust. It is possible that the certificate is in fact signed by a CA that we don't directly trust, but that in turn is signed by a CA that we do trust. These are known as intermediate Certificate Authorities and are part of what's known as the certificate chain. There may be more than one intermediate CA in a chain. In our simple setup we will not be using any intermediate CAs.
At the top of the chain sits a root Certificate Authority. Since we trust the root CA, we also implicitly trust any intermediate CA it has signed and in turn any leaf certificates such an intermediate CA has signed.
A root Certificate Authority is special in that it has no CA above it to sign in. It is self-signed.
To create our own root CA for our Vespa installation we'll first create its private key.
We have two choices of what kind of key to create; either based on RSA
or Elliptic Curve (EC)
cryptography. EC keys are faster to process than RSA-based keys and take up less space, but older
OS versions or cryptographic libraries may not support these (see
Application deployment fails with
In the latter case, RSA keys offer the highest level of backwards compatibility.
(Recommended) either create an Elliptic Curve private key:
OR: create an RSA private key:
The root CA private key is stored in
root-ca.key. This key is used to sign certificates and the
file MUST therefore be kept secret! If it is compromised, an attacker can create any number of
valid certificates that impersonate your Vespa hosts.
We'll now create our CA X.509 certificate, self-signed with the private key. Substitute the information
-subj with whatever is appropriate for you; it's not really important for our
Copy the resulting
root-ca.pem file to your Vespa node(s) and point the
field in the TLS config file to its absolute file path on the node.
With both the CA key and certificate, we have what we need to start signing certificates for the hosts Vespa will be running on.
Note: This section can be repeated for each Vespa host in your application. See Alternatives to having a unique certificate per individual host for (possibly less secure) options that do not require doing this step per host.
Just like our CA our host needs its own private cryptographic key.
If we're using Elliptic Curve keys:
OR: if we're using RSA keys:
As part of creating the certificate we'll first create a Certificate Signing Request (CSR).
Again, you can substitute the information in
-subj with something more appropriate for you.
By default, Vespa runs with TLS hostname validation enabled, which requires the server's certificate
to contain a hostname matching what the client is connecting to. This is fundamental to the security
of protocols such as HTTP, but often sees less use with mTLS. Vespa supports it as an added layer of
security. Using certificates containing hostnames has the added benefit that you can run tools such
curl against Vespa HTTPS status pages without having to explicitly disable certificate verification.
Certificates can contain many entries known as "Subject Alternate Names" (SANs) that list what DNS names and IP addresses the certificate is issued for. We'll add a single such DNS SAN entry with the hostname of our node. We'll also use the opportunity to add certain X.509 extensions to the certificate that specifies exactly what the certificate can be used for.
myhost.example.com with the hostname of your Vespa node.
We can now use our existing CA key and certificate to sign the host's CSR, additionally providing the above file of certificate extensions to OpenSSL.
This creates an X.509 certificate in PEM format for the host, valid for 3650 days from the time of signing.
We can inspect the certificate using the
openssl x509 command. Here's some example output
for a certificate using EC keys. Your output will look different since the serial
number, dates and key information etc. will differ.
host.pem to your Vespa host and point the
"certificates" TLS config fields to their respective absolute paths. The CSR and
extension config files can be safely discarded.
host.keyis only readable by the Vespa user on your host(s)
It's possible to avoid having to create a separate certificate per host in favor of a single certificate shared between all hosts.
bar.vespa.example.com) it's possible to use a wildcard DNS SAN entry (
*.vespa.example.com) instead of listing all hosts.
However, for production deployments we recommend using a distinct certificate per host to help mitigate the impact of a host being compromised.