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

gh-91826: Enable cert and hostname verification for stdlib #91875

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

tiran
Copy link
Member

@tiran tiran commented Apr 24, 2022

@tiran
Copy link
Member Author

tiran commented Apr 24, 2022

Several tests are failing.

@erlend-aasland erlend-aasland changed the title gh-91826: [WIP] Enable cert and hostname verification for stdlib gh-91826: Enable cert and hostname verification for stdlib Jan 4, 2024
Smattr added a commit to Smattr/needtoknow that referenced this pull request Feb 2, 2024
The Python docs say:¹

  _ssl_context_ is a `ssl.SSLContext` object which allows bundling SSL
  configuration options, certificates and private keys into a single
  (potentially long-lived) structure. Please read Security considerations
  for best practices.
  …
  For client use, if you don’t have any special requirements for your security
  policy, it is highly recommended that you use the `create_default_context()`
  function to create your SSL context. It will load the system’s trusted CA
  certificates, enable certificate validation and hostname checking, and try to
  choose reasonably secure protocol and cipher settings.
  …
  By contrast, if you create the SSL context by calling the `SSLContext`
  constructor yourself, it will not have certificate validation nor hostname
  checking enabled by default.

While this is clear, it is counter-intuitive behaviour of which I was unaware.
I only learned of this through an oss-sec posting.² This issue seems to have a
long history and we are not the only software affected by it.³

¹ https://docs.python.org/3/library/imaplib.html#imaplib.IMAP4_SSL
² https://www.openwall.com/lists/oss-security/2024/02/01/4
³ python/cpython#91826,
  https://peps.python.org/pep-0476/,
  python/cpython#91875,
  https://www.pentagrid.ch/en/blog/python-mail-libraries-certificate-verification/,
  python/peps#3537
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants