The Fix
pip install urllib3==1.25
Based on closed urllib3/urllib3 issue #1275 · PR/commit linked
Production note: Most teams hit this during upgrades or environment changes. Roll out with a canary and smoke critical endpoints (health, OpenAPI/docs) before 100%.
@@ -8,6 +8,12 @@ dev (master)
* Upgraded ``urllib3.utils.parse_url()`` to be RFC 3986 compliant. (Issue #)
+* Added support for ``key_password`` for ``HTTPSConnectionPool`` to use
+ encrypted ``key_file`` without creating your own ``SSLContext`` object. (Pull #1489)
+
def load_cert_chain(self, certfile, keyfile=None, password=None):
self._ctx.use_certificate_file(certfile)
if password is not None:
self._ctx.set_passwd_cb(lambda max_length, prompt_twice, userdata: six.binary_type(password))
self._ctx.use_privatekey_file(keyfile or certfile)
Re-run the minimal reproduction on your broken version, then apply the fix and re-run.
Option A — Upgrade to fixed release\npip install urllib3==1.25\nWhen NOT to use: This fix is not suitable if the application requires strict type handling for passwords.\n\n
Why This Fix Works in Production
- Trigger: Make sure PyOpenSSLContext.load_cert_chain sets password as byte string
- Mechanism: Adds support for password-protected client keyfiles in `HTTPSConnectionPool`, allowing encrypted key files to be used without creating a custom `SSLContext`.
- Why the fix works: Adds support for password-protected client keyfiles in `HTTPSConnectionPool`, allowing encrypted key files to be used without creating a custom `SSLContext`. (first fixed release: 1.25).
- If left unfixed, the same config can fail only in production (env differences), causing startup failures or partial feature outages.
Why This Breaks in Prod
- Production symptom (often without a traceback): Make sure PyOpenSSLContext.load_cert_chain sets password as byte string
Proof / Evidence
- GitHub issue: #1275
- Fix PR: https://github.com/urllib3/urllib3/pull/1489
- First fixed release: 1.25
- Reproduced locally: No (not executed)
- Last verified: 2026-02-09
- Confidence: 0.95
- Did this fix it?: Yes (upstream fix exists)
- Own content ratio: 0.64
Discussion
High-signal excerpts from the issue thread (symptoms, repros, edge-cases).
“Why should the cast come in urllib3 and not in user code? I’m not opposed to adding the cast but the downside of adding it…”
“Mainly for convenience”
Failure Signature (Search String)
- Make sure PyOpenSSLContext.load_cert_chain sets password as byte string
- I ran into an issue creating a TransportAdapter using an SSL Context with a passpharse due to the fact that pyopenssl expects a byte string and not unicode (see
Copy-friendly signature
Failure Signature
-----------------
Make sure PyOpenSSLContext.load_cert_chain sets password as byte string
I ran into an issue creating a TransportAdapter using an SSL Context with a passpharse due to the fact that pyopenssl expects a byte string and not unicode (see https://github.com/pyca/pyopenssl/issues/701).
Error Message
Signature-only (no traceback captured)
Error Message
-------------
Make sure PyOpenSSLContext.load_cert_chain sets password as byte string
I ran into an issue creating a TransportAdapter using an SSL Context with a passpharse due to the fact that pyopenssl expects a byte string and not unicode (see https://github.com/pyca/pyopenssl/issues/701).
Minimal Reproduction
def load_cert_chain(self, certfile, keyfile=None, password=None):
self._ctx.use_certificate_file(certfile)
if password is not None:
self._ctx.set_passwd_cb(lambda max_length, prompt_twice, userdata: six.binary_type(password))
self._ctx.use_privatekey_file(keyfile or certfile)
What Broke
Users experienced blocking behavior when using encrypted key files without providing a password.
Fix Options (Details)
Option A — Upgrade to fixed release Safe default (recommended)
pip install urllib3==1.25
Use when you can deploy the upstream fix. It is usually lower-risk than long-lived workarounds.
Fix reference: https://github.com/urllib3/urllib3/pull/1489
First fixed release: 1.25
Last verified: 2026-02-09. Validate in your environment.
When NOT to Use This Fix
- This fix is not suitable if the application requires strict type handling for passwords.
Verify Fix
Re-run the minimal reproduction on your broken version, then apply the fix and re-run.
Did This Fix Work in Your Case?
Quick signal helps us prioritize which fixes to verify and improve.
Prevention
- Add a CI check that diffs key outputs after upgrades (OpenAPI schema snapshots, JSON payload shapes, CLI output).
- Upgrade behind a canary and run integration tests against the canary before 100% rollout.
- Add a TLS smoke test that performs a real handshake in CI (include CA bundle validation and hostname checks).
- Alert on handshake failures by error string and endpoint to catch cert/CA changes quickly.
Version Compatibility Table
| Version | Status |
|---|---|
| 1.25 | Fixed |
Related Issues
No related fixes found.
Sources
We don’t republish the full GitHub discussion text. Use the links above for context.