gh-91826: Document that smtplib/poplib/ftplib TLS defaults do not verify certs - #154712
Closed
Vamsi-klu wants to merge 1 commit into
Closed
gh-91826: Document that smtplib/poplib/ftplib TLS defaults do not verify certs#154712Vamsi-klu wants to merge 1 commit into
Vamsi-klu wants to merge 1 commit into
Conversation
…ot verify certs Mirror the imaplib note from pythongh-72507 / PR python#152778 so users of SMTP, POP and FTP TLS APIs know the default context encrypts but does not authenticate. Also list the four modules in Doc/library/security_warnings.rst.
Documentation build overview
4 files changed± library/ftplib.html± library/poplib.html± library/security_warnings.html± library/smtplib.html |
|
Codex Review: Didn't find any major issues. Keep them coming! Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
Vamsi-klu
marked this pull request as draft
July 26, 2026 08:01
Author
|
Closing this PR. Thank you for the review attention. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Documentation-only follow-up to the long-standing issue that the stdlib mail/FTP TLS clients encrypt by default without verifying the peer certificate or hostname. This does not flip any runtime defaults (that remains PEP-gated on gh-91826). It closes the "users had no idea" half of the problem the same way gh-72507 / PR #152778 already did for
imaplib.Fixes part of gh-91826 (docs slice only).
What the issue is
smtplib,poplib,ftplib(and historicallyimaplib) obtain their defaultSSLContextfromssl._create_stdlib_context, which is an alias ofssl._create_unverified_context(cert_reqs=CERT_NONE,check_hostname=False). The connection is encrypted, but:imaplibalready documents this (merged PR #152778). Users who only readsmtplib/poplib/ftplibstill had no in-tree warning, andDoc/library/security_warnings.rstdid not list these modules either. That is a documentation gap on a security-sensitive default, independent of whether/when the default is flipped.Why I solved it that way
IMAP4_SSL/IMAP4.starttls. Reusing it avoids inventing a second house style and makes the four modules consistent.*ssl_context*; the others use*context*. The note text uses the local parameter name so it matches the signature the reader is looking at.security_warnings.rstbullets. That page is the stdlib index of "look here before you ship." Listing all four modules (including imaplib for completeness) matches howssl/http.server/ etc. are already called out.I deliberately did not:
ssl._create_stdlib_context,DeprecationWarnings,logging.handlers.SMTPHandler,Those belong in separate workstreams so this PR stays reviewable in minutes.
How I did it
Doc/library/smtplib.rstSMTP_SSLandSMTP.starttlsDoc/library/poplib.rstPOP3_SSLandPOP3.stlsDoc/library/ftplib.rstFTP_TLS(nearcontext)Doc/library/security_warnings.rstftplib,imaplib,poplib,smtplibEach note is:
Impact
Testing plan
.rstfiles (passed locally via pre-commit hook).make -C Doc htmlor CI docs job) to confirm no broken refs tossl.create_default_context.No unit tests: pure documentation.
Everything else
ftplib.FTP_TLS#143497 (FTP_TLSPROT P default), stale PR gh-91826: Enable cert and hostname verification for stdlib #91875 (full flip), draft PEP 738.needs backport to 3.15,3.14,3.13if desired after merge.