Fix SSL hostname verification bug and update env var names#83
Open
taylorleese wants to merge 4 commits intoredis:mainfrom
Open
Fix SSL hostname verification bug and update env var names#83taylorleese wants to merge 4 commits intoredis:mainfrom
taylorleese wants to merge 4 commits intoredis:mainfrom
Conversation
|
Hi, I’m Jit, a friendly security platform designed to help developers build secure applications from day zero with an MVS (Minimal viable security) mindset. In case there are security findings, they will be communicated to you as a comment inside the PR. Hope you’ll enjoy using Jit. Questions? Comments? Want to learn more? Get in touch with us. |
This commit addresses two issues: 1. **SSL Hostname Verification Bug**: Fixed the error "Cannot set verify_mode to CERT_NONE when check_hostname is enabled" by adding support for the `ssl_check_hostname` parameter. When `REDIS_SSL_CERT_REQS=none` is set, hostname checking is now automatically disabled by default, matching the behavior of redis-cli's --insecure flag. This is essential for scenarios like AWS SSM port forwarding where the connection goes to localhost but the certificate is issued for the actual hostname. 2. **Environment Variable Naming**: Fixed inconsistencies in documentation (.env.example, README.md, smithery.yaml) where SSL-related environment variables were missing the "SSL_" prefix. Updated: - REDIS_CA_PATH → REDIS_SSL_CA_PATH - REDIS_CERT_REQS → REDIS_SSL_CERT_REQS - REDIS_CA_CERTS → REDIS_SSL_CA_CERTS Changes: - Added REDIS_SSL_CHECK_HOSTNAME configuration option - Automatically sets check_hostname=False when cert_reqs="none" - Added ssl_check_hostname support in parse_redis_uri() - Passed ssl_check_hostname to both Redis and RedisCluster connections - Added comprehensive tests for the new functionality - Updated documentation to reflect correct variable names
1351460 to
079ebd6
Compare
vchomakov
reviewed
Nov 4, 2025
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #83 +/- ##
=======================================
Coverage ? 86.03%
=======================================
Files ? 18
Lines ? 795
Branches ? 0
=======================================
Hits ? 684
Misses ? 111
Partials ? 0
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
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.
Summary
This PR fixes a bug that causes SSL connections to fail with the error "Cannot set verify_mode to CERT_NONE when check_hostname is enabled" when using
REDIS_SSL_CERT_REQS=none. It also corrects inconsistent environment variable naming in the documentation.1. SSL Hostname Verification Bug Fix
Problem: When setting
REDIS_SSL_CERT_REQS=none, the server would crash with:This happens because Python's SSL library requires that when
verify_mode=ssl.CERT_NONE, thecheck_hostnameparameter must also be set toFalse.Use Case: This is essential for scenarios like AWS SSM port forwarding, where:
localhost:6379(via the tunnel)localhost ≠ aws-hostname.amazonaws.comSolution: Added
REDIS_SSL_CHECK_HOSTNAMEconfiguration that:FalsewhenREDIS_SSL_CERT_REQS=noneredis-cli --insecure2. Environment Variable Naming Fixes
Fixed inconsistencies in
.env.example,README.md, andsmithery.yamlwhere some SSL variables were missing theSSL_prefix:REDIS_CA_PATH→REDIS_SSL_CA_PATHREDIS_CERT_REQS→REDIS_SSL_CERT_REQSREDIS_CA_CERTS→REDIS_SSL_CA_CERTSThese now match the actual variable names used in
src/common/config.py.Changes
REDIS_SSL_CHECK_HOSTNAMEconfiguration option toconfig.pycert_reqs="none"ssl_check_hostnamesupport inparse_redis_uri()for URI-based configssl_check_hostnameto both Redis and RedisCluster connectionsTest Plan
REDIS_SSL_CERT_REQS=noneno longer crashesredis-cli --tls --insecurebehavior is matchedssl_check_hostnameconfigurationRelated
This addresses the issue discovered while debugging AWS SSM port forwarding connections where the certificate hostname doesn't match the forwarded localhost address.