Skip to content

Use verify_name in TLS examples and README - #1403

Merged
uglide merged 1 commit into
masterfrom
im/tls-verify-name-docs
Nov 19, 2026
Merged

uglide merged 1 commit into
masterfrom
im/tls-verify-name-docs

Conversation

@uglide

@uglide uglide commented Nov 19, 2026 •

Copy link
Copy Markdown
Contributor

Why

#1355 added the opt-in verify_name option, but the TLS examples and the README sample still create their context with redisCreateSSLContext(). 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.c and examples/example-libevent-ssl.c switch to redisCreateSSLContextWithOptions() with REDIS_SSL_VERIFY_PEER and verify_name set to the host being connected to.
  • The README sample uses the options struct with verify_name, and connects to the same name it verifies.
  • A new README subsection, "Verifying the server's identity", explains that:
    • without verify_name any certificate from a trusted CA is accepted, and redisCreateSSLContext() cannot set it;
    • server_name is SNI only and is not checked against the certificate;
    • verify_name requires REDIS_SSL_VERIFY_PEER;
    • the expected name belongs to the redisSSLContext, so use one context per server name.
  • The redisInitiateSSL() bullet now says hiredis does not configure verification for caller-managed SSL objects.

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 Host Before After
example-ssl localhost / 127.0.0.1 not run connects
example-ssl name not in the certificate connects rejected, certificate verify failed
example-libevent-ssl localhost / 127.0.0.1 not run connects
example-libevent-ssl name not in the certificate connects rejected
  • Makefile build (USE_SSL=1) of both examples: no warnings.
  • CMake build with -Werror and examples enabled: no warnings; TEST_SSL=1 ./test.sh passes. CMake only builds example-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_name peer identity checks instead of the older redisCreateSSLContext() pattern, which only validates the CA chain.

The README SSL sample switches to redisCreateSSLContextWithOptions() with REDIS_SSL_VERIFY_PEER and verify_name matching the connect host, notes that caller-managed SSL * objects need their own hostname setup, and adds a "Verifying the server's identity" subsection contrasting verify_name, server_name (SNI), and the legacy wrapper.

example-ssl.c and example-libevent-ssl.c use the same options struct and set verify_name to 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.

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.
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 19, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-19T14:41:42.666266Z e039b5b PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@github-actions

Copy link
Copy Markdown

ABI compatibility check

✅ libhiredis — compatible

No ABI changes detected.

✅ libhiredis_ssl — compatible

No ABI changes detected.

Baseline e90c24e2239395ea4eb4972cb14eb7a77a778d7b vs head e039b5b3c673bea01c0dee5e7744124ae209f782. Apply the ignore-abi-check label to skip this check for an intentional, SONAME-bumped ABI break.

@uglide
uglide merged commit 5afee36 into master Nov 19, 2026
43 of 46 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant