Repository navigation
Use verify_name in TLS examples and README - #1403
Merged
Merged
Conversation
The TLS examples and the README sample created their context with redisCreateSSLContext(), which validates the CA chain only and cannot request peer name verification. Switch them to redisCreateSSLContextWithOptions() with verify_name set to the host being connected to, so the documented pattern binds the connection to the intended server identity. Document in the README that server_name is SNI only, that without verify_name any certificate from a trusted CA is accepted, and that callers of redisInitiateSSL() must configure identity verification on their own SSL object.
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
ABI compatibility check✅
|
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.
Why
#1355 added the opt-in
verify_nameoption, but the TLS examples and the README sample still create their context withredisCreateSSLContext(). That wrapper validates the CA chain only and has no way to request peer name verification, so the pattern we document accepts any certificate issued by a trusted CA, whatever identity it carries.What changes
examples/example-ssl.candexamples/example-libevent-ssl.cswitch toredisCreateSSLContextWithOptions()withREDIS_SSL_VERIFY_PEERandverify_nameset to the host being connected to.verify_name, and connects to the same name it verifies.verify_nameany certificate from a trusted CA is accepted, andredisCreateSSLContext()cannot set it;server_nameis SNI only and is not checked against the certificate;verify_namerequiresREDIS_SSL_VERIFY_PEER;redisSSLContext, so use one context per server name.redisInitiateSSL()bullet now says hiredis does not configure verification for caller-managedSSLobjects.No library code changes.
Behavior change in the examples
The examples now reject a server whose certificate does not carry the host passed on the command line. Connecting by a name or IP that is missing from the certificate's SAN entries will fail where it used to succeed.
Verification
Ubuntu 24.04, OpenSSL 3.0.13, against a TLS Redis whose certificate carries
DNS:localhost, IP:127.0.0.1:example-ssllocalhost/127.0.0.1example-sslcertificate verify failedexample-libevent-ssllocalhost/127.0.0.1example-libevent-sslUSE_SSL=1) of both examples: no warnings.-Werrorand examples enabled: no warnings;TEST_SSL=1 ./test.shpasses. CMake only buildsexample-ssl, so the libevent example was checked with the Makefile build.The async example reports the rejection as
Error: Success; that is a library error-reporting issue fixed separately in #1402.🤖 Generated with Claude Code
Note
Low Risk
Docs and example-only changes; no library behavior changes, though copied example code will now enforce certificate hostname verification.
Overview
Documentation and TLS examples now demonstrate
verify_namepeer identity checks instead of the olderredisCreateSSLContext()pattern, which only validates the CA chain.The README SSL sample switches to
redisCreateSSLContextWithOptions()withREDIS_SSL_VERIFY_PEERandverify_namematching the connect host, notes that caller-managedSSL *objects need their own hostname setup, and adds a "Verifying the server's identity" subsection contrastingverify_name,server_name(SNI), and the legacy wrapper.example-ssl.candexample-libevent-ssl.cuse the same options struct and setverify_nameto the CLI hostname, so connections fail if the certificate does not carry that name even when the CA is trusted.There are no library code changes; behavior change is limited to the documented examples.
Reviewed by Cursor Bugbot for commit e039b5b. Bugbot is set up for automated code reviews on this repo. Configure here.