Add optional ssl config flag
To address https://github.com/elementary-data/elementary/issues/1801 I'm proposing to add a new CLI boolean flag flag --use-system-ca-files/--no-use-system-ca-files to let the user decide when to use the system root CAs or the certifi ones.
The default value is false to keep it backward compatible.
Summary by CodeRabbit
- New Features
- Added configurable SSL/TLS certificate handling for Slack connections, enabling custom SSL context configuration.
- Introduced
--use-system-ca-filesCLI flag (default enabled) to allow users to choose between system or bundled certificate authorities for secure connections.
Walkthrough
The changes add SSL context handling to Slack clients and introduce a system CA file configuration option. A new ssl_context parameter is added to SlackClient and its subclasses, while a new use_system_ca_files configuration flag is introduced in Config and wired through the CLI monitor and send_report commands.
Changes
| Cohort / File(s) | Summary |
|---|---|
Slack Client SSL Context Support elementary/clients/slack/client.py |
Added ssl_context parameter to SlackClient.__init__ and _initial_client methods. Updated SlackWebClient and SlackWebhookClient to accept and propagate ssl_context to parent class and underlying Slack API clients. Added ssl and certifi imports for CA bundle handling. |
Config System CA Flag elementary/config/config.py |
Added use_system_ca_files: bool = True parameter to Config.__init__ and assigned to self.use_system_ca_files attribute. |
CLI System CA Option elementary/monitor/cli.py |
Added --use-system-ca-files/--no-use-system-ca-files CLI flag (default True) to common monitor options. Updated monitor and send_report command signatures to accept and propagate use_system_ca_files to Config construction. |
Estimated code review effort
🎯 3 (Moderate) | ⏱️ ~25 minutes
- Areas requiring attention:
- Verify SSL context is correctly instantiated and passed through all three Slack client classes (SlackClient, SlackWebClient, SlackWebhookClient)
- Confirm
ssl_contextparameter propagation chain from CLI flag → Config → Slack client initialization - Check that default behavior (system CA files) matches expected SSL/TLS validation behavior
- Validate that the certifi and ssl imports are correctly used in client creation
Poem
🐰 A rabbit hops through certificates and keys, Where Slack now speaks with custom SSL ease, From CLI flags to clients passing through, System CAs or bundles—the choice is true! 🔒
Pre-merge checks and finishing touches
❌ Failed checks (1 warning, 1 inconclusive)
| Check name | Status | Explanation | Resolution |
|---|---|---|---|
| Docstring Coverage | ⚠️ Warning | Docstring coverage is 14.29% which is insufficient. The required threshold is 80.00%. | You can run @coderabbitai generate docstrings to improve docstring coverage. |
| Title check | ❓ Inconclusive | The title 'Add optional ssl config flag' is vague and generic, using non-descriptive terms that don't convey the specific purpose of the change. | Provide a more specific title that describes what the flag does, such as 'Add --use-system-ca-files CLI flag to control SSL certificate validation' or similar. |
✅ Passed checks (1 passed)
| Check name | Status | Explanation |
|---|---|---|
| Description Check | ✅ Passed | Check skipped - CodeRabbit’s high-level summary is enabled. |
✨ Finishing touches
- [ ] 📝 Generate docstrings
🧪 Generate unit tests (beta)
- [ ] Create PR with unit tests
- [ ] Post copyable unit tests in a comment
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 @coderabbitai help to get the list of available commands and usage tips.