ocean
ocean copied to clipboard
Add opt-out controls to bypass strict X.509 verification introduced in Python 3.13 or disable SSL verification at all
User description
Description
Summary
This PR introduces flexible SSL verification controls for both Port API calls and third‑party integrations. It adds opt‑out switches that let you bypass the new strict verification (VERIFY_X509_STRICT) when needed, and optionally disable SSL verification entirely (not recommended).
What changed
- Added an SSL configuration helper that can build custom SSL contexts to:
- Disable only the strict X.509 path checks added in Python 3.13+
- Or disable SSL verification entirely
- Applied these settings in:
- Port API HTTP client initialization
- Shared third‑party HTTP client initialization (used by integrations)
- Added documentation describing the configuration and usage
Environment variables
Port API connections
PORT_OCEAN_NO_STRICT_VERIFY=true- Bypasses the strict X.509 verification introduced in Python 3.13+
PORT_OCEAN_VERIFY_SSL=false- Disables SSL verification entirely (not recommended)
Third‑party integration connections
PORT_OCEAN_THIRD_PARTY_NO_STRICT_VERIFY=true- Bypasses strict X.509 verification for third‑party requests
PORT_OCEAN_THIRD_PARTY_VERIFY_SSL=false- Disables SSL verification entirely for third‑party requests (not recommended)
Notes
- Default behavior remains unchanged; all verification stays enabled unless these env vars are explicitly set.
- Custom CA configuration still relies on HTTPX/OpenSSL standard envs:
SSL_CERT_FILE,SSL_CERT_DIR,REQUESTS_CA_BUNDLE(no changes here). - These toggles are intended for environments with private PKI/self‑signed chains that fail due to Python 3.13’s stricter checks.
Security considerations
- Prefer
*_NO_STRICT_VERIFY=trueover disabling verification entirely. - Avoid
*_VERIFY_SSL=falsein production; it disables hostname and certificate validation and increases MITM risk.
Docs
- Added/updated guidance under framework docs: SSL configuration and advanced configuration for per‑client settings and examples.
Examples
- Bypass strict chain checks only (Python 3.13+):
- Port API:
export PORT_OCEAN_NO_STRICT_VERIFY=true - Third‑party:
export PORT_OCEAN_THIRD_PARTY_NO_STRICT_VERIFY=true
- Port API:
- Disable all SSL verification (not recommended):
- Port API:
export PORT_OCEAN_VERIFY_SSL=false - Third‑party:
export PORT_OCEAN_THIRD_PARTY_VERIFY_SSL=false
- Port API:
Reasoning
Many enterprises use internal CAs or self‑signed chains. Python 3.13’s VERIFY_X509_STRICT can break previously working chains. These switches provide a controlled, explicit opt‑out while maintaining secure defaults.
Type of change
Please leave one option from the following and delete the rest:
- [ ] New feature (non-breaking change which adds functionality)
All tests should be run against the port production environment(using a testing org).
Core testing checklist
- [ ] Integration able to create all default resources from scratch
- [ ] Resync finishes successfully
- [ ] Resync able to create entities
- [ ] Resync able to update entities
- [ ] Resync able to detect and delete entities
- [ ] Scheduled resync able to abort existing resync and start a new one
- [ ] Tested with at least 2 integrations from scratch
- [ ] Tested with Kafka and Polling event listeners
- [ ] Tested deletion of entities that don't pass the selector
PR Type
Enhancement
Description
-
Add SSL context configuration helper supporting Python 3.13+ strict verification bypass
-
Implement separate SSL controls for Port API and third-party integrations
-
Apply SSL settings to both Port and third-party HTTP clients
-
Document SSL configuration with environment variables and security guidance
Diagram Walkthrough
flowchart LR
A["Environment Variables"] -->|"OCEAN__VERIFY_SSL<br/>OCEAN__NO_STRICT_VERIFY_SSL"| B["get_ssl_context<br/>SSLClientType.PORT"]
A -->|"OCEAN__THIRD_PARTY_VERIFY_SSL<br/>OCEAN__THIRD_PARTY_NO_STRICT_VERIFY_SSL"| C["get_ssl_context<br/>SSLClientType.THIRD_PARTY"]
B -->|"ssl.SSLContext or bool"| D["Port API Client"]
C -->|"ssl.SSLContext or bool"| E["Third-Party Client"]
D --> F["HTTP Requests"]
E --> F
File Walkthrough
| Relevant files | |||||||
|---|---|---|---|---|---|---|---|
| Enhancement |
| ||||||
| Documentation |
|