-
Notifications
You must be signed in to change notification settings - Fork 73
Fix SSL hostname verification bug and update env var names #83
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
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
| | `REDIS_SSL_CERTFILE` | Client's certificate file for client authentication | None | | ||
| | `REDIS_SSL_CERT_REQS` | Certificate requirements (none, optional, or required) | `"required"` | | ||
| | `REDIS_SSL_CA_CERTS` | Path to the trusted CA certificates file | None | | ||
| | `REDIS_SSL_CHECK_HOSTNAME` | Verify SSL certificate hostname (auto-disabled when cert_reqs=none)| `True` | |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
when REDIS_SSL_CERT_REQS=none
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:
|
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.