forked from loafle/openapi-generator-original
[python] fix tests, tornado ssl fix (#6968)
* fix: non-zero exit code if tests fail * tests: use local petserver to run tests * fix: non-zero exit code if tests fail * tests: use local petserver to run tests * fix: creating ssl context in old version of Python * chore: remove unused target from Makefile * doc: changes from upstream * fix: tornado client raises NotImplementedError in older version of Python
This commit is contained in:
committed by
William Cheng
parent
c6ffbd38ad
commit
73cb68ee7b
@@ -51,12 +51,20 @@ class RESTClientObject(object):
|
||||
# if not set certificate file, use Mozilla's root certificates.
|
||||
ca_certs = certifi.where()
|
||||
|
||||
self.ssl_context = ssl.create_default_context(ssl.Purpose.CLIENT_AUTH)
|
||||
self.ssl_context.load_verify_locations(cafile=ca_certs)
|
||||
if configuration.cert_file:
|
||||
self.ssl_context.load_cert_chain(
|
||||
configuration.cert_file, keyfile=configuration.key_file
|
||||
)
|
||||
if hasattr(ssl, 'create_default_context'):
|
||||
# require Python 2.7.9+, 3.4+
|
||||
self.ssl_context = ssl.create_default_context()
|
||||
self.ssl_context.load_verify_locations(cafile=ca_certs)
|
||||
if configuration.cert_file:
|
||||
self.ssl_context.load_cert_chain(
|
||||
configuration.cert_file, keyfile=configuration.key_file
|
||||
)
|
||||
|
||||
elif configuration.cert_file or configuration.ssl_ca_cert:
|
||||
raise NotImplementedError('SSL requires Python 2.7.9+, 3.4+')
|
||||
|
||||
else:
|
||||
self.ssl_context = None
|
||||
|
||||
self.proxy_port = self.proxy_host = None
|
||||
|
||||
|
||||
Reference in New Issue
Block a user