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

Fix #173: HTTPS request doesn't work when disable_ssl_certificate_validation=True #288

Closed
wants to merge 2 commits into from

Conversation

r14c
Copy link

@r14c r14c commented Nov 25, 2014

Sets SSLContext.verify_mode to ssl.CERT_OPTIONAL if disable_ssl_certificate_validation is True otherwise it is set to ssl.CERT_REQUIRED.

Sets `SSLContext.verify_mode` to `ssl.CERT_OPTIONAL` if `disable_ssl_certificate_validation` is `True` otherwise it is set to `ssl.CERT_REQUIRED`.
raise CertificateValidationUnsupportedInPython31()
context = ssl.SSLContext(ssl.PROTOCOL_TLSv1)
if not hasattr(ssl, 'SSLContext'):
raise CertificateValidationUnsupportedInPython31()
Copy link

Choose a reason for hiding this comment

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

I'm pretty sure this causes Python 3.1 to always raise an exception, even when certification validation is explicitly not disabled, - i.e. when disable_ssl_certificate_validation is enabled.

fwiw, there is another pending patch for this issue; pull #269 , which has bitrotted.

Copy link
Author

Choose a reason for hiding this comment

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

@jayvdb you are totally right, I'll update the patch.

* `ssl.SSLContext` is new in Python 3.2 and all of the features
  used here are available from then on.
* The when using an `SSLContext` the `check_hostname` kwarg *requires*
  that `context.verify_mode` be set to **either** `ssl.CERT_REQUIRED`
  **or** `ssl.CERT_OPTIONAL`. `ssl.CERT_NONE` raises an exception.
@r14c r14c closed this Oct 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants