Repository navigation
Conversation
…#3522)" This reverts commit 13c66b8. Refusing to configure TLS when tls-ca-cert-dir holds no certificates is a breaking change, and the TSC decided the fail-fast certificate checks wait for a major release. The check lives inside loadCaCertDir(), which valkey-io#2999 added, so it has to go before valkey-io#2999 can be reverted. Related to valkey-io#5506. Signed-off-by: Madelyn Olson <madelyneolson@gmail.com>
…io#2999)" This reverts commit eb3f465. Refusing to configure TLS when any loaded certificate is outside its validity period breaks configurations that worked in 9.1 and earlier. An expired intermediate or root left in a tls-ca-cert-file bundle after a CA rotation is normal and harmless, since OpenSSL simply does not build chains through it, but the check walks the whole X509_STORE and rejects the configuration on the first expired entry, so a server that served traffic fine on 9.1.3 refuses to start on 9.2.0. The TSC decided these checks are a breaking change that waits for a major release, and reverted them from 9.1 in valkey-io#3572. The next release turned out to be 9.2 rather than 10.0, and the revert was never carried over, so 9.2.0 shipped them. Restore the 9.1 behavior on 9.x. unstable keeps the checks for 10.0. The alternate-certificate check that valkey-io#3717 added is removed along with the primary one, so both server certificates behave the same way on 9.x. Reported-by: Philippe <31954718+Qwarctick@users.noreply.github.com> Signed-off-by: Madelyn Olson <madelyneolson@gmail.com>
Owner
Author
|
Promoted upstream: valkey-io#5550 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes valkey-io#5506
Since 9.2.0, valkey-server refuses to configure TLS when any certificate it loads is outside its validity period, so an expired old root left in a
tls-ca-cert-filebundle after a CA rotation stops the server from starting, even though OpenSSL would never build a chain through that cert. 9.1.3 starts fine on the same files. The checks came from valkey-io#2999 and valkey-io#3522, which the TSC decided were a breaking change: valkey-io#3572 reverted them from 9.1 and the plan was to land them in the next major, but the next release turned out to be 9.2 rather than 10.0 and the revert was never carried over. These two commits revert them from the 9.2 branch so 9.x behaves like 9.1 again;unstablekeeps them for 10.0.AI generated details
Problem
createSSLContext()onupstream/9.2validates every certificate it loads and aborts the whole TLS configuration if any one of them is expired or not yet valid:src/tls.c:653for the server and client certificates,src/tls.c:675for the alternate server certificate,src/tls.c:719for the contents of the X509 store aftertls-ca-cert-fileandtls-ca-cert-dirare loaded.areAllCaCertsValid()atsrc/tls.c:586walks the whole store and returns false on the first expired entry.That makes a normal CA rotation fatal. A bundle that still carries the retired root alongside the current one worked on 9.1 and earlier, because OpenSSL simply does not build chains through an expired cert, and nothing in the handshake path cares that it is present. On 9.2.0 the same files stop the server from starting. From valkey-io#5506, same config and same cert files on both versions:
The same applies at runtime, where
CONFIG SET tls-ca-cert-fileon such a bundle now fails and keeps the old configuration.History
unstable2026-01-28) added the checks fortls-cert-file,tls-client-cert-file,tls-ca-cert-fileandtls-ca-cert-dir, plusloadCaCertDir()to eagerly loadtls-ca-cert-dirso the CA check could see those certs at all.unstablekept it because the next release was expected to be 10.0.loadCaCertDir()to also abort whentls-ca-cert-dirholds no certificates. Both PRs are labeledbreaking-change.unstableon 2026-09-16 and 9.2.0 shipped both PRs, with no release note.Affected releases: 9.2.0 only. Not 9.1.x, where valkey-io#3572 removed it, and not 8.x, which predates valkey-io#2999. Target release for this revert is 9.2.1.
Fix
Two commits, in the order the dependency requires, so each can be read against a plain
git revert.Revert "Fail fast on empty CA directory at TLS config load (valkey-io/valkey#3522)"is byte-for-byte a plaingit revert 13c66b82e: no later commit touched those hunks. It has to come first because its abort lives insideloadCaCertDir(), which valkey-io#2999 introduced.Revert "Fail fast on invalid certificates at TLS config load (valkey-io/valkey#2999)"conflicts with six later 9.2-only commits and is resolved by hand, per file:src/tls.cisCertValid(),loadCaCertDir(),areAllCaCertsValid()and all four call sites. Kept#include <dirent.h>and#include <limits.h>, which a plain revert drops but valkey-io#2913'stlsUpdateCertInfoFromDir()still needs (src/tls.c:389,src/tls.c:397). Restored the CA block to 9.1's single combined condition, which is now character-identical toupstream/9.1:src/tls.c. Everything valkey-io#3717, valkey-io#4663, valkey-io#4664, valkey-io#4577 and valkey-io#2913 added tocreateSSLContext()is untouched.src/tls.c:43#include <openssl/x509_vfy.h>is left in place even though this revert removes its last direct consumers (X509_STORE_get0_objects,X509_OBJECT_*,X509_LU_X509, and valkey-io#4064'sX509_V_ERR_ERROR_IN_CERT_NOT_{BEFORE,AFTER}_FIELD). The line belongs to valkey-io#3717, which is not being reverted, andssl.hpulls the header in transitively anyway, so dropping it is a cleanup outside this revert rather than part of it. Say the word and it goes; 9.1 does not have it.src/tls.c(valkey-io#4064)isCertValid(), so it goes with the function.isCertValid()has no caller that is not a fail-fast abort, so there is nothing left to keep it for.tests/unit/tls.tcltest_tls_cert_rejection*procs and both tests. The plain revert conflicts because a later commit swapped[file normalize ./src/valkey-tls.so]for$::VALKEY_TLS_MODULEand./src/valkey-serverfor$::VALKEY_SERVER_BINinside the removed block. Nothing else in the repo references the certs these tests used.utils/gen-test-certs.shtests/README.mdOne call a reviewer may want to make differently:
src/tls.c:675, the alternate-certificate abort, is not from valkey-io#2999. valkey-io#3717 added secondary certificate support in 9.2 and copied valkey-io#2999's check for the second certificate, so a plain revert of valkey-io#2999 would leave it behind. Keeping it would mean the primary certificate's expiry is ignored at config load while the secondary's is fatal, on the same server, in the same function, five lines apart. That is a worse surface to explain and support than either consistent choice, so it goes with the rest. Reinstating it for 10.0 is one line and belongs with the rest of the fail-fast work thatunstablealready carries.Behavior
Every cell is a server started with
--tls-port, a validtls-cert-file/tls-key-fileunless the row says otherwise, and the listed CA configuration. The cell is the log line the server printed. Base isupstream/9.2atd23684e3, built locally; 9.1.3 and 9.2.0 are the officialvalkey/valkeyimages. Raw output is below.d23684e3/ 9.2.0tls-ca-cert-file ca.crt)Ready to accept connections tlsReady to accept connections tlsReady to accept connections tlstls-ca-cert-file)One or more loaded CA certificates are invalid. Aborting TLS configuration.Ready to accept connections tlsReady to accept connections tlstls-ca-cert-dirOne or more loaded CA certificates are invalid. Aborting TLS configuration.Ready to accept connections tlsReady to accept connections tlstls-ca-cert-dirNo CA certificates loaded from directory: <dir>Ready to accept connections tlsReady to accept connections tlstls-cert-fileServer TLS certificate is invalid. Aborting TLS configuration.Ready to accept connections tlsReady to accept connections tlstls-alt-cert-fileAlternate server TLS certificate is invalid. Aborting TLS configuration.Ready to accept connections tlstls-alt-cert-filedoes not exist in 9.1The branch column matches the 9.1.3 column in every row where 9.1.3 has a value. The base column is identical to the released 9.2.0 column in every row, so the local base build is a faithful stand-in.
The expired-CA rows use a bundle of the valid test CA plus a separately-issued expired CA with a different subject, which is the reporter's rotation case: nothing chains through the expired cert.
One capability does go away with
loadCaCertDir()Reverting valkey-io#2999 removes the eager
tls-ca-cert-dirload, which means OpenSSL is back to its documented-CApathcontract: certificates in that directory are found by subject-hash symlink, not by filename. 9.2.0 accidentally made a directory of plain-named.crtfiles work for peer verification, becauseloadCaCertDir()pushed every parseable file straight into the X509 store. Verified by handshaking a client certificate against a server configured withtls-ca-cert-dironly andtls-auth-clients yes:The branch matches 9.1.3, which is the point of the revert, and
utils/gen-test-certs.shalready builds the hashedca-dir/the tests use. KeepingloadCaCertDir()just for this would keep the eager scan whose zero-cert case is exactly what valkey-io#3522 then turned into an abort, so it goes.Nobody on the 9.1 to 9.2.1 path can be relying on this, but somebody on the 9.2.0 to 9.2.1 path can, and for them the regression is silent:
SSL_CTX_load_verify_locationsregisters a directory lazily, so the server starts normally and then fails every handshake withcertificate verify failed. That is the same silent-misconfiguration shape valkey-io#3522 was written to prevent. It is narrow, since it needs a dir-only CA config that actually verifies peers (tls-auth-clientsnotno, ortls-cluster/tls-replication), and the capability was never documented or tested as "plain filenames work". It does mean the 9.2.1 note has to name it rather than just say the checks were reverted.The 9.1.3 alternate-certificate row is blank because 9.1 has no such config and exits before TLS setup:
Alternative considered
Warn instead of fail, as valkey-io#3153 proposed. It is strictly better than aborting, and it is the shape the eventual 10.0 behavior should probably take, but it still changes what 9.2.1 logs and what operators' log scrapers see relative to 9.1, for a check the TSC decided does not belong in a minor release at all. It also leaves
loadCaCertDir()in place, which means 9.2 keeps eagerly scanningtls-ca-cert-dirat config load, a behavior change of its own that 9.1 does not have, and that is where valkey-io#3522's empty-directory abort grew from.An opt-out config such as
tls-verify-cert-validity-at-load. That puts a new user-visible config into a patch release, which needs a TSC vote on its own, and 10.0 would then have to deprecate it the moment the fail-fast behavior becomes the documented default. A knob whose only purpose is to undo a change we have already decided to undo is worse than undoing the change.Neither option gets 9.2 back to the behavior its users had in 9.1, which is the actual requirement for a patch release.
Testing
No new regression test. This restores behavior that 9.1 never had a test for, on a release branch whose
unstablecounterpart deliberately asserts the opposite. A test that pins "starting with an expired CA in the bundle succeeds" would have to be deleted again when 10.0 lands the fail-fast checks. The matrix above is the evidence instead.The tests removed with valkey-io#2999 were the only coverage of these paths, and they asserted exactly the aborts being removed, so there is nothing left in
tests/unit/tls.tclthat can detect this change in either direction../runtest --tls --single unit/tls --loops 3: 93 passed, 0 failed.make BUILD_TLS=moduleplus./runtest --tls-module --single unit/tls: 26 passed, 0 failed. Both builds clean with no new warnings, in anubuntu:24.04container with OpenSSL 3.0.13 andtcl-tls.Release notes
Not touched here, and
00-RELEASENOTESneeds more than one line when 9.2.1 is cut. The 9.2.0 GA section currently advertises two of the three behaviors this removes, and both are false on 9.2.1:valkey-io#2999 itself appears nowhere in the file, so the main fail-fast behavior is undocumented in both directions. The historical 9.2.0 section should not be edited; the 9.2.1 entry should cover all three removals, including the
tls-ca-cert-dirhash-name requirement above, which is the one with a silent failure mode.This was generated by AI but verified, with love, by a human.