Skip to content
Myr

Simplify fix for #4025

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by Jonas Laursen · committed by Cory Benfield · parent af66521 · Browse files · 1 file+32 added−31 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

1 file+32 added−31 removed

  • other:+32 added−31 removed

1 file+32 added−31 removed

modified:requests/adapters.py+32 added-31 removed
207 unmodified lines
208 the server's TLS certificate, or a string, in which case it must be a path209 to a CA bundle to use210 :param cert: The SSL certificate to verify.211 """212 if url.lower().startswith('https'):213 if verify:214 cert_loc = None212 if url.lower().startswith('https') and verify:213216 # Allow self-specified cert location.217 if verify is not True:218 cert_loc = verify214 cert_loc = None215220 if not cert_loc:221 cert_loc = DEFAULT_CA_BUNDLE_PATH216 # Allow self-specified cert location.217 if verify is not True:218 cert_loc = verify219223 if not cert_loc or not os.path.exists(cert_loc):224 raise IOError("Could not find a suitable TLS CA certificate bundle, "225 "invalid path: {0}".format(cert_loc))220 if not cert_loc:221 cert_loc = DEFAULT_CA_BUNDLE_PATH222227 conn.cert_reqs = 'CERT_REQUIRED'223 if not cert_loc or not os.path.exists(cert_loc):224 raise IOError("Could not find a suitable TLS CA certificate bundle, "225 "invalid path: {0}".format(cert_loc))226229 if not os.path.isdir(cert_loc):230 conn.ca_certs = cert_loc231 else:232 conn.ca_cert_dir = cert_loc227 conn.cert_reqs = 'CERT_REQUIRED'228229 if not os.path.isdir(cert_loc):230 conn.ca_certs = cert_loc231 else:232 conn.ca_cert_dir = cert_loc233 else:234 conn.cert_reqs = 'CERT_NONE'235 conn.ca_certs = None236 conn.ca_cert_dir = None234 conn.cert_reqs = 'CERT_NONE'235 conn.ca_certs = None236 conn.ca_cert_dir = None237238 if cert:239 if not isinstance(cert, basestring):240 conn.cert_file = cert[0]241 conn.key_file = cert[1]242 else:243 conn.cert_file = cert244 if conn.cert_file and not os.path.exists(conn.cert_file):245 raise IOError("Could not find the TLS certificate file, "246 "invalid path: {0}".format(conn.cert_file))247 if conn.key_file and not os.path.exists(conn.key_file):248 raise IOError("Could not find the TLS key file, "249 "invalid path: {0}".format(conn.key_file))238 if cert:239 if not isinstance(cert, basestring):240 conn.cert_file = cert[0]241 conn.key_file = cert[1]242 else:243 conn.cert_file = cert244 conn.key_file = None245 if conn.cert_file and not os.path.exists(conn.cert_file):246 raise IOError("Could not find the TLS certificate file, "247 "invalid path: {0}".format(conn.cert_file))248 if conn.key_file and not os.path.exists(conn.key_file):249 raise IOError("Could not find the TLS key file, "250 "invalid path: {0}".format(conn.key_file))251252 def build_response(self, req, resp):253 """Builds a :class:`Response <requests.Response>` object from a urllib3254 response. This should not be called from user code, and is only exposed
265 unmodified lines