Skip to content

Commit 3951d59

Browse files
committed
Don't call curl.unsetopt(pycurl.CAINFO) to reset CA certificates to default.
This doesn't work because it clobbers the default CA certs, causing all certificates to be rejected. There doesn't seem to be any way to restore the defaults, so just leave it untouched in the default case and document the requirement that all requests use ca_certs if any do.
1 parent e7ee4e1 commit 3951d59

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

tornado/httpclient.py

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -425,6 +425,11 @@ def __init__(self, url, method="GET", headers=None, body=None,
425425
# validate_cert: boolean, set to False to disable validation
426426
# ca_certs: filename of CA certificates in PEM format, or
427427
# None to use defaults
428+
# Note that in the curl-based HTTP client, if any request
429+
# uses a custom ca_certs file, they all must (they don't have to
430+
# all use the same ca_certs, but it's not possible to mix requests
431+
# with ca_certs and requests that use the defaults).
432+
# SimpleAsyncHTTPClient does not have this limitation.
428433
self.validate_cert = validate_cert
429434
self.ca_certs = ca_certs
430435
self.start_time = time.time()
@@ -567,7 +572,13 @@ def _curl_setup_request(curl, request, buffer, headers):
567572
if request.ca_certs is not None:
568573
curl.setopt(pycurl.CAINFO, request.ca_certs)
569574
else:
570-
curl.unsetopt(pycurl.CAINFO)
575+
# There is no way to restore pycurl.CAINFO to its default value
576+
# (Using unsetopt makes it reject all certificates).
577+
# I don't see any way to read the default value from python so it
578+
# can be restored later. We'll have to just leave CAINFO untouched
579+
# if no ca_certs file was specified, and require that if any
580+
# request uses a custom ca_certs file, they all must.
581+
pass
571582

572583
# Set the request method through curl's retarded interface which makes
573584
# up names for almost every single method

0 commit comments

Comments
 (0)