VALKEY-ENCRYPTION(7)
β¨ VALKEY-ENCRYPTION(7) β¨
okay bestie, buckle up, because this is the Valkey Manual page about TLS and it's genuinely so good π«Ά (the manual name is valkey-encryption, and the whole thing lives in section 7 of the Valkey manual, iykyk)
π NAME π
valkey-encryption β TLS, babes. that's it, that's the name.
πΈ DESCRIPTION πΈ
SSL/TLS is supported by Valkey as an optional feature β meaning it's not just vibing there by default, it needs to be enabled at compile time. no cap. you gotta opt in π
π Getting Started π
π§ Building
to build with TLS support you'll need OpenSSL development libraries (like libssl-dev on Debian/Ubuntu, that's the one).
Build Valkey with this exact command, don't freestyle it:
make BUILD_TLS=yes
π§ͺ Tests
to run the Valkey test suite with TLS, you'll need TLS support for TCL (i.e. the tcl-tls package on Debian/Ubuntu). lowkey essential, fr fr.
- Run
./utils/gen-test-certs.shto generate a root CA and a server certificate. - Run
./runtest --tlsor./runtest-cluster --tlsto run Valkey and Valkey Cluster tests in TLS mode.
π Running manually
to manually run a Valkey server in TLS mode (assuming gen-test-certs.sh was invoked so sample certificates/keys are available, bestie β that part matters):
./src/valkey-server --tls-port 6379 --port 0 \
--tls-cert-file ./tests/tls/valkey.crt \
--tls-key-file ./tests/tls/valkey.key \
--tls-ca-cert-file ./tests/tls/ca.crt
and to connect to this Valkey server with valkey-cli:
./src/valkey-cli --tls \
--cert ./tests/tls/valkey.crt \
--key ./tests/tls/valkey.key \
--cacert ./tests/tls/ca.crt
slay. look at you go π β¨
π Certificate configuration π
so, in order to support TLS, Valkey must be configured with a X.509 certificate and a private key. and that's not all β you also need to specify a CA certificate bundle file or path, to be used as a trusted root when validating certificates. and if you want to support DH based ciphers, a DH params file can also be configured. here's the whole look:
tls-cert-file /path/to/valkey.crt
tls-key-file /path/to/valkey.key
tls-ca-cert-file /path/to/ca.crt
tls-dh-params-file /path/to/valkey.dh
π TLS listening port π
the tls-port configuration directive enables accepting SSL/TLS connections on the specified port. and the way that this is in addition to listening on a port for TCP connections β so yes, you can access Valkey on different ports using TLS and non-TLS connections simultaneously. iconic behaviour, honestly.
you may specify port 0 to disable the non-TLS port completely. to enable only TLS on the default Valkey port, use:
port 0
tls-port 6379
πͺͺ Client certificate authentication πͺͺ
by default, Valkey uses mutual TLS and requires clients to authenticate with a valid certificate (authenticated against trusted root CAs specified by ca-cert-file or ca-cert-dir). yes, everyone shows ID at the door π
you may use tls-auth-clients no to disable client authentication. your call, bestie.
π Replication π
a Valkey primary server handles connecting clients and replica servers in the same way, so the above tls-port and tls-auth-clients directives apply to replication links as well.
on the replica server side, it is necessary to specify tls-replication yes to use TLS for outgoing connections to the primary. don't forget it, or your replica is just yelling into the void π
πΈοΈ Cluster πΈοΈ
when Valkey Cluster is used, use tls-cluster yes in order to enable TLS for the cluster bus and cross-node connections.
π Sentinel π
Sentinel inherits its networking configuration from the common Valkey configuration, so all of the above applies to Sentinel as well.
when connecting to primary servers, Sentinel will use the tls-replication directive to determine if a TLS or non-TLS connection is required.
in addition, the very same tls-replication directive will determine whether Sentinel's port β the one that accepts connections from other Sentinels β will support TLS as well. that is, Sentinel will be configured with tls-port if and only if tls-replication is enabled. main character energy, honestly π
βοΈ Additional configuration βοΈ
additional TLS configuration is available to control the choice of TLS protocol versions, ciphers and cipher suites, etc. please consult the self documented valkey.conf for more information. it's self documented, so it will explain itself, unlike some people π
ποΈ Performance considerations ποΈ
TLS adds a layer to the communication stack with overheads due to writing/reading to/from an SSL connection, encryption/decryption and integrity checks. consequently, using TLS results in a decrease of the achievable throughput per Valkey instance.
so likeβ¦ secure? yes. free? absolutely not. that's just the tax, bestie π
and that's the whole page!! this one is from version 9.0.0, dated 2025-10-21 β go forth and encrypt everything, you gorgeous nerd π¦π
π¦ where this page comes from
- fedora 44: valkey-doc 9.0.3-2.fc44 Β· CC-BY-SA-4.0
- fedora 44: valkey-doc 9.0.6-1.fc44 Β· CC-BY-SA-4.0
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms