Repository navigation
Conversation
redisSSLRead() and redisSSLWrite() reported every failure through __redisSetError(c, REDIS_ERR_IO, NULL), which builds the message from errno. For SSL_ERROR_SSL no system call failed, so errno is typically 0 and the error text was "Success". This is most visible on non-blocking contexts: the TLS handshake is completed by the first reads/writes rather than by SSL_connect(), so a rejected server certificate (untrusted CA, verify_name mismatch, ...) reached the async disconnect callback as "Success" with no usable reason. Take the reason from the OpenSSL error queue for SSL_ERROR_SSL, as redisSSLConnect() already does, and keep the errno based message for everything else. Add a polling-adapter test that fails an async handshake with a verify_name mismatch and checks the reported error.
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✅
|
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using high effort and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit d9540ef. Configure here.
| } | ||
| } | ||
| __redisSetError(c, REDIS_ERR_IO, NULL); | ||
| } |
There was a problem hiding this comment.
SSL error fallback still uses errno
Low Severity
When the failure is SSL_ERROR_SSL but ERR_reason_error_string returns NULL, redisSSLSetIOError still calls __redisSetError with a NULL message, so errstr is filled from errno. No syscall failed in this case, so that text is often Success, which is the misleading message this helper exists to avoid. redisSSLConnect already substitutes unknown error when the OpenSSL reason is missing.
Reviewed by Cursor Bugbot for commit d9540ef. Configure here.
|
Hey @uglide , looks good to me. I ran the tests on darwin/openssl 3.5.9, all pass, and the new test fails without the ssl.c change, so all looks good there. I played a bit with the blocking path since the description says its not affected. For the cert check thats true, but i found two cases where the read still looses the openssl reason. Both are old, they are on master too, not from this pr - so up to you if you want them here or in a follow up.
In (thats on ubuntu 24.04 with openssl 3.0.13, on mac i get "Undefined error: 0" and "record layer failure")
redis with the One nit on the helper - i don't know if its worth the effort to be super defensive here, but in rare cases like openssl builds without error strings, const char *reason = ERR_reason_error_string(ERR_peek_last_error());
- if (reason) {
- char msg[256];
- snprintf(msg, sizeof(msg), "SSL error: %s", reason);
- __redisSetError(c, REDIS_ERR_IO, msg);
- return;
- }
+ char msg[256];
+ snprintf(msg, sizeof(msg), "SSL error: %s",
+ reason ? reason : "unknown error");
+ __redisSetError(c, REDIS_ERR_IO, msg);
+ return;
}
__redisSetError(c, REDIS_ERR_IO, NULL);Repro is below if you want to play with it, its one file and needs only docker: docker run --rm -i ubuntu:24.04 bash < pr-1402-repro.shit builds hiredis from this PR inside the container and runs both cases. You can pass
|


Problem
redisSSLRead()andredisSSLWrite()report every failure through__redisSetError(c, REDIS_ERR_IO, NULL), which builds the message fromerrno. ForSSL_ERROR_SSLno system call failed, soerrnois typically 0 and the error text isSuccess.This is most visible on non-blocking contexts. There the TLS handshake is completed by the first reads/writes rather than by
SSL_connect(), so a rejected server certificate (untrusted CA,verify_namemismatch, expired certificate, ...) reaches the async disconnect callback as:The blocking path is not affected:
redisSSLConnect()already reads the reason from the OpenSSL error queue.Fix
Add a small helper,
redisSSLSetIOError(), that takes the reason from the OpenSSL error queue when the failure isSSL_ERROR_SSLand keeps theerrnobased message for everything else. The non-blocking branch ofredisSSLRead()and the error branch ofredisSSLWrite()use it. The same failure now reads:Test
A new polling-adapter test fails an async handshake with a
verify_namemismatch and checks that the callback receivesREDIS_ERR_IOwith anSSL error:message. It needs no libevent and runs with the existing TLS tests. It fails without thessl.cchange.Verification
Ubuntu 24.04, OpenSSL 3.0.13:
USE_SSL=1) and CMake build (-Werror, SSL, SSL tests, async tests, examples): no warnings.TEST_SSL=1 ./test.sh: all tests pass with both builds.Not tested locally: macOS, Windows, BoringSSL.
Note
#1390 touches the same two functions (it clears the error queue before the I/O call). The changes are complementary and edit different lines of
ssl.c, but both add a test call at the same place intest.c, so whichever lands second needs a trivial conflict resolution.🤖 Generated with Claude Code
Note
Low Risk
Small, localized change to SSL error reporting in the non-blocking read/write paths, with a targeted regression test; no API or handshake logic changes.
Overview
Fixes misleading "Success" I/O errors when async TLS handshakes fail during the first
SSL_read/SSL_write(e.g. certificate orverify_namerejection), becauseSSL_ERROR_SSLputs the reason on OpenSSL’s error queue rather than inerrno.Adds
redisSSLSetIOError(), which formatsSSL error: <reason>fromERR_peek_last_error()forSSL_ERROR_SSLand otherwise keeps the existingerrno-based path.redisSSLRead()andredisSSLWrite()now call it instead of__redisSetError(..., NULL).Adds
test_ssl_async_handshake_failure_reason, which forces averify_namemismatch on a polling async SSL connection and asserts the disconnect/connect callback seesREDIS_ERR_IOwith anSSL error:prefix. It runs with the existing SSL verify-name tests.Reviewed by Cursor Bugbot for commit d9540ef. Bugbot is set up for automated code reviews on this repo. Configure here.