Skip to content
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

Move to TLS client protocol for http connections #191

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion duo_client/https_wrapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,13 +69,15 @@ def __init__(self, host, port=None, key_file=None, cert_file=None,
can't be parsed as a valid HTTP/1.0 or 1.1 status line.
"""
six.moves.http_client.HTTPConnection.__init__(self, host, port, strict, **kwargs)
context = ssl.SSLContext(ssl.PROTOCOL_SSLv23)
context = ssl.SSLContext(ssl.PROTOCOL_TLS_CLIENT)
if cert_file:
context.load_cert_chain(cert_file, key_file)
if ca_certs:
context.verify_mode = ssl.CERT_REQUIRED
context.load_verify_locations(cafile=ca_certs)
else:
# Can't check hostnames if we're not requiring server certificates
context.check_hostname = False
Copy link
Contributor Author

@AaronAtDuo AaronAtDuo Jan 25, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PROTOCOL_TLS_CLIENT automatically makes check_hostname True (side note, that means PROTOCOL_SSLv23 and PROTOCOL_TLS don't?) but if we don't require certs, we obviously can't required hostname checking.

context.verify_mode = ssl.CERT_NONE

ssl_version_blacklist = ssl.OP_NO_SSLv2 | ssl.OP_NO_SSLv3
Expand Down