Title: SDK does not respect SSL_CERT_FILE or REQUESTS_CA_BUNDLE environment variables · Issue #998 · massive-com/client-python · GitHub
Open Graph Title: SDK does not respect SSL_CERT_FILE or REQUESTS_CA_BUNDLE environment variables · Issue #998 · massive-com/client-python
X Title: SDK does not respect SSL_CERT_FILE or REQUESTS_CA_BUNDLE environment variables · Issue #998 · massive-com/client-python
Description: Problem The Polygon Python SDK fails with SSL certificate verification errors when used behind corporate firewalls that perform SSL/TLS inspection. The SDK does not respect standard SSL certificate environment variables (SSL_CERT_FILE, R...
Open Graph Description: Problem The Polygon Python SDK fails with SSL certificate verification errors when used behind corporate firewalls that perform SSL/TLS inspection. The SDK does not respect standard SSL certificate...
X Description: Problem The Polygon Python SDK fails with SSL certificate verification errors when used behind corporate firewalls that perform SSL/TLS inspection. The SDK does not respect standard SSL certificate...
Opengraph URL: https://github.com/massive-com/client-python/issues/998
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"SDK does not respect SSL_CERT_FILE or REQUESTS_CA_BUNDLE environment variables","articleBody":"## Problem\n\nThe Polygon Python SDK fails with SSL certificate verification errors when used behind corporate firewalls that perform SSL/TLS inspection. The SDK does not respect standard SSL certificate environment variables (`SSL_CERT_FILE`, `REQUESTS_CA_BUNDLE`) that specify custom CA bundles.\n\n## Steps to Reproduce\n\n```python\nimport os\nfrom polygon import RESTClient\n\n# Set custom CA bundle (common in enterprise environments)\nos.environ[\"SSL_CERT_FILE\"] = \"/path/to/corporate-ca-bundle.pem\"\n\n# This fails with SSL error\nclient = RESTClient(os.getenv(\"POLYGON_API_KEY\"))\naggs = client.get_aggs(ticker=\"AAPL\", multiplier=1, timespan=\"day\",\n from_=\"2026-02-01\", to=\"2026-02-10\")\nlist(aggs) # SSLError: certificate verify failed\n```\n\n## Expected Behaviour\n\nSDK should respect SSL environment variables like other Python HTTP libraries (requests, httpx, urllib3).\n\n## Actual Behaviour\n\n```\nSSLError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed:\nself-signed certificate in certificate chain\n```\n\nSDK ignores environment variables and uses bundled certifi CA bundle only.\n\n## Evidence\n\n**Raw Python SSL (works):**\n```python\nimport ssl, socket\ncontext = ssl.create_default_context()\nwith socket.create_connection((\"api.polygon.io\", 443)) as sock:\n with context.wrap_socket(sock, server_hostname=\"api.polygon.io\") as s:\n print(s.version()) # ✅ TLSv1.3 - Success!\n```\n\n**Polygon SDK (fails):**\nUses bundled certs, ignores `SSL_CERT_FILE` → certificate verification fails.\n\n## Root Cause\n\nThe SDK uses `urllib3` but doesn't configure it to check standard SSL environment variables. While `urllib3` supports custom CA bundles, the Polygon SDK never provides them.\n\n## Comparison: Alpaca SDK (Works Correctly)\n\n```python\n# Alpaca SDK respects SSL_CERT_FILE and works behind corporate firewalls\nfrom alpaca.data.historical import StockHistoricalDataClient\nclient = StockHistoricalDataClient(api_key, secret_key)\nbars = client.get_stock_bars(...) # ✅ Works!\n```\n\n## Suggested Fix\n\nCheck environment variables when creating HTTP client:\n\n```python\nimport os\nimport certifi\n\ndef get_ca_bundle():\n \"\"\"Get CA bundle from environment or default.\"\"\"\n return (os.getenv(\"SSL_CERT_FILE\") or\n os.getenv(\"REQUESTS_CA_BUNDLE\") or\n certifi.where())\n\n# Use in RESTClient\nhttp = urllib3.PoolManager(cert_reqs=\"CERT_REQUIRED\",\n ca_certs=get_ca_bundle())\n```\n\n## Impact\n\n**Affects:** Enterprise users behind corporate firewalls with SSL inspection (finance, healthcare, government sectors)\n\n**Current workarounds:** All unacceptable for production:\n- ❌ Disable SSL verification (insecure)\n- ❌ Switch to different provider\n- ❌ Maintain local SDK patches\n\n## Environment\n\n- **Python:** 3.10+\n- **OS:** macOS/Linux\n- **Network:** Corporate firewall with SSL inspection (Zscaler, etc.)\n- **polygon-api-client:** Latest\n\n## References\n\n- urllib3 docs: https://urllib3.readthedocs.io/en/stable/advanced-usage.html#custom-ssl-certificates\n- Example implementation: [alpaca-py SDK](https://github.com/alpacahq/alpaca-py)\n- Standard practice: requests, httpx, aiohttp all respect these env vars\n\nHappy to submit a PR if maintainers are open to this fix.\nThis issue generated with AI/Claude 4.6\n","author":{"url":"https://github.com/farmerbean","@type":"Person","name":"farmerbean"},"datePublished":"2026-02-12T16:50:11.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":0},"url":"https://github.com/998/client-python/issues/998"}
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:53fbb8af-243c-6161-3664-aa1754e2162b |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | E1DE:F61E5:180B625:2186024:6A4DF653 |
| html-safe-nonce | bce226858543747ccff165b31debf3124a90b059d667efc0e192d3c7f52cb824 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJFMURFOkY2MUU1OjE4MEI2MjU6MjE4NjAyNDo2QTRERjY1MyIsInZpc2l0b3JfaWQiOiI4NzI5ODA1MjQxNzc0MzcyNDM1IiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | 3c9f45b0bfa2edc104df71ef06b14babd40faaf15aeba1f994adb3dc7762bcdd |
| hovercard-subject-tag | issue:3932862906 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/massive-com/client-python/998/issue_layout |
| twitter:image | https://opengraph.githubassets.com/686d061e3bee7f15ec5a5fe20b67358fcb3a27817ec2b3a294caf71b670cc7b6/massive-com/client-python/issues/998 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/686d061e3bee7f15ec5a5fe20b67358fcb3a27817ec2b3a294caf71b670cc7b6/massive-com/client-python/issues/998 |
| og:image:alt | Problem The Polygon Python SDK fails with SSL certificate verification errors when used behind corporate firewalls that perform SSL/TLS inspection. The SDK does not respect standard SSL certificate... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | farmerbean |
| hostname | github.com |
| expected-hostname | github.com |
| None | 5818716c93c6a2925b815402541a32814e43a7b1261c322b0c2df75224289566 |
| turbo-cache-control | no-preview |
| go-import | github.com/massive-com/client-python git https://github.com/massive-com/client-python.git |
| octolytics-dimension-user_id | 191946194 |
| octolytics-dimension-user_login | massive-com |
| octolytics-dimension-repository_id | 216660192 |
| octolytics-dimension-repository_nwo | massive-com/client-python |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 216660192 |
| octolytics-dimension-repository_network_root_nwo | massive-com/client-python |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 4314b1df11fa8a565684f3a72dc971e3785da365 |
| ui-target | canary-2 |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width