feat: support HTTPS connections and SSL verification bypass#620
Conversation
|
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
example_external_session.py (1)
52-73:⚠️ Potential issue | 🟠 Major | ⚡ Quick winThe shared root cause is insecure-first guidance for TLS verification. The PR introduces a useful bypass capability, but both the runnable example and docs currently present
ssl_verify=Falseas a primary/default path, which can propagate MITM-prone usage patterns.
example_external_session.py#L52-L73: keep SSL-bypass as an explicit opt-in/troubleshooting example, and stop running it as the default__main__entrypoint.README.md#L54-L66: add a clear warning thatssl_verify=Falsedisables certificate validation and show the secure (ssl_verify=True) path first.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@example_external_session.py` around lines 52 - 73, The code is currently presenting insecure SSL verification bypass as the default example, which promotes unsafe MITM-prone usage patterns. At example_external_session.py lines 52-73, remove or replace the `example_with_https_and_ssl_bypass()` function call from the `if __name__ == "__main__":` block; either create a secure example function (with `ssl_verify=True` as the default) as the primary entrypoint, or make the SSL-bypass example an explicit opt-in (e.g., commented out or accessible by a command-line flag). At README.md lines 54-66, add a prominent security warning that `ssl_verify=False` disables certificate validation and exposes the connection to MITM attacks, then reorder the documentation to show the secure path (with `ssl_verify=True`) as the primary/recommended approach before mentioning the bypass option for troubleshooting only.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@openevsehttp/commands.py`:
- Around line 439-442: The `_firmware_check_with_session` method applies the
`ssl_verify` setting to GitHub API requests, which compromises security for
external trusted services. Since this method exclusively fetches from GitHub's
trusted API (https://api.github.com), which has valid CA-signed certificates,
the SSL bypass logic should not apply here. Remove the conditional check that
sets kwargs["ssl"] = False based on self.ssl_verify within this method, ensuring
GitHub API requests always use proper TLS certificate verification regardless of
the user's local device SSL settings.
---
Outside diff comments:
In `@example_external_session.py`:
- Around line 52-73: The code is currently presenting insecure SSL verification
bypass as the default example, which promotes unsafe MITM-prone usage patterns.
At example_external_session.py lines 52-73, remove or replace the
`example_with_https_and_ssl_bypass()` function call from the `if __name__ ==
"__main__":` block; either create a secure example function (with
`ssl_verify=True` as the default) as the primary entrypoint, or make the
SSL-bypass example an explicit opt-in (e.g., commented out or accessible by a
command-line flag). At README.md lines 54-66, add a prominent security warning
that `ssl_verify=False` disables certificate validation and exposes the
connection to MITM attacks, then reorder the documentation to show the secure
path (with `ssl_verify=True`) as the primary/recommended approach before
mentioning the bypass option for troubleshooting only.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 75cbefc1-d0b0-40cc-8c2e-91a16deaa633
📒 Files selected for processing (7)
README.mdexample_external_session.pyopenevsehttp/client.pyopenevsehttp/commands.pyopenevsehttp/websocket.pytests/test_client.pytests/test_websocket.py
|
We have addressed the outside-diff review comments:
|
Summary
Adds support for HTTPS connections to the OpenEVSE charger and introduces options to bypass SSL certificate validation for both HTTP requests and WebSocket connections.
Details
ssl: bool = Falseandssl_verify: bool = Trueparameters. Constructsself.urlwith thehttpsscheme whensslisTrueandhttpotherwise._process_request_with_sessioninOpenEVSEand_firmware_check_with_sessioninCommandsMixinto passssl=Falsetoaiohttprequests when using HTTPS with disabled SSL certificate validation.OpenEVSEWebsocketconstructor to receivessl_verifyand passssl=Falsetosession.ws_connectwhen using a secure WebSocket (wss://) with validation bypassed.example_external_session.pyand updatedREADME.mdto document the newsslandssl_verifyparameters.Testing
test_ssl_optionsintests/test_client.pycovering url construction andssl=Falserequest kwarg passing.test_websocket_ssl_optionsintests/test_websocket.pycovering secure websocket uri construction and parameter passing.Context
Enables connecting to OpenEVSE modules running secure local servers with self-signed SSL/TLS certificates, laying the groundwork for secure downstream integration in systems like Home Assistant.
Summary by CodeRabbit
New Features
Documentation
Tests