-
Notifications
You must be signed in to change notification settings - Fork 1.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Update TLS check to use TLS context wrapper #8230
Conversation
499068b
to
89a21c6
Compare
Codecov Report
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍 for docs
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You're breaking backwards compatibility, you have to use TLS_CONFIG_REMAPPER
for this.
ea25abd
to
8a9eb7b
Compare
184219b
to
16ae6cd
Compare
16ae6cd
to
1fe3ba4
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Almost good ! A few extra comments
def tls_context(self): | ||
if self._tls_context is None: | ||
# https://docs.python.org/3/library/ssl.html#ssl.SSLContext | ||
# https://docs.python.org/3/library/ssl.html#ssl.PROTOCOL_TLS | ||
self._tls_context = ssl.SSLContext(protocol=PROTOCOL_TLS_CLIENT) | ||
|
||
# Run our own validation later on if need be | ||
# https://docs.python.org/3/library/ssl.html#ssl.SSLContext.check_hostname | ||
# | ||
# IMPORTANT: This must be set before verify_mode in Python 3.7+, see: | ||
# https://docs.python.org/3/library/ssl.html#ssl.SSLContext.check_hostname | ||
self._tls_context.check_hostname = False | ||
|
||
# https://docs.python.org/3/library/ssl.html#ssl.SSLContext.verify_mode | ||
self._tls_context.verify_mode = ssl.CERT_REQUIRED if self._validate_cert else ssl.CERT_NONE | ||
|
||
# https://docs.python.org/3/library/ssl.html#ssl.SSLContext.load_verify_locations | ||
if self._cafile or self._capath: # no cov | ||
self._tls_context.load_verify_locations(self._cafile, self._capath, None) | ||
|
||
# https://docs.python.org/3/library/ssl.html#ssl.SSLContext.load_default_certs | ||
else: | ||
self._tls_context.load_default_certs(ssl.Purpose.SERVER_AUTH) | ||
|
||
# https://docs.python.org/3/library/ssl.html#ssl.SSLContext.load_cert_chain | ||
if self._cert: # no cov | ||
self._tls_context.load_cert_chain(self._cert, keyfile=self._private_key) | ||
|
||
# https://docs.python.org/3/library/ssl.html#ssl.create_default_context | ||
if 'SSLv3' in self._allowed_versions: # no cov | ||
self._tls_context.options &= ~ssl.OP_NO_SSLv3 | ||
|
||
return self._tls_context |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Currently seeing how to ensure the logic of creating this context while also using updated SSL context
What does this PR do?
This PR updates the TLS check to use the new SSL context wrapper rather than creating it from scratch.
Motivation
Additional Notes
Review checklist (to be filled by reviewers)
changelog/
andintegration/
labels attached