Skip to content

gh-114905: Test that ssl._create_stdlib_context() rejects check_hostname with CERT_NONE - #155509

Merged
serhiy-storchaka merged 1 commit into
python:mainfrom
serhiy-storchaka:gh-114905-ssl-check-hostname
Aug 13, 2026
Merged

gh-114905: Test that ssl._create_stdlib_context() rejects check_hostname with CERT_NONE#155509
serhiy-storchaka merged 1 commit into
python:mainfrom
serhiy-storchaka:gh-114905-ssl-check-hostname

Conversation

@serhiy-storchaka

@serhiy-storchaka serhiy-storchaka commented Aug 10, 2026

Copy link
Copy Markdown
Member

Pin the current behaviour of ssl._create_stdlib_context() with check_hostname, and explain in a comment why check_hostname is assigned before verify_mode.

With PROTOCOL_TLS_CLIENT, which became the default protocol in 3.10, this is an error. With an explicitly specified legacy protocol it used to succeed, silently raising verify_mode to CERT_REQUIRED and ignoring the requested CERT_NONE.

No caller of _create_stdlib_context() in the standard library passes check_hostname, so no public API reaches it.

…_hostname with CERT_NONE

With PROTOCOL_TLS_CLIENT, which became the default protocol in 3.10, this is
an error.  With an explicitly specified legacy protocol it used to succeed,
silently raising verify_mode to CERT_REQUIRED and ignoring the requested
CERT_NONE.

No caller of ssl._create_stdlib_context() in the standard library passes
check_hostname, so no public API reaches it.
@serhiy-storchaka
serhiy-storchaka merged commit 726e485 into python:main Aug 13, 2026
52 checks passed
@serhiy-storchaka
serhiy-storchaka deleted the gh-114905-ssl-check-hostname branch August 13, 2026 09:43
@serhiy-storchaka serhiy-storchaka added tests Tests in the Lib/test dir needs backport to 3.13 bugs and security fixes needs backport to 3.14 bugs and security fixes needs backport to 3.15 pre-release feature fixes, bugs and security fixes labels Aug 13, 2026
@miss-islington-app

Copy link
Copy Markdown

Thanks @serhiy-storchaka for the PR 🌮🎉.. I'm working now to backport this PR to: 3.13.
🐍🍒⛏🤖

@miss-islington-app

Copy link
Copy Markdown

Thanks @serhiy-storchaka for the PR 🌮🎉.. I'm working now to backport this PR to: 3.14.
🐍🍒⛏🤖

@miss-islington-app

Copy link
Copy Markdown

Thanks @serhiy-storchaka for the PR 🌮🎉.. I'm working now to backport this PR to: 3.15.
🐍🍒⛏🤖

@bedevere-app

bedevere-app Bot commented Aug 13, 2026

Copy link
Copy Markdown

GH-155670 is a backport of this pull request to the 3.13 branch.

@bedevere-app bedevere-app Bot removed the needs backport to 3.13 bugs and security fixes label Aug 13, 2026
@bedevere-app

bedevere-app Bot commented Aug 13, 2026

Copy link
Copy Markdown

GH-155671 is a backport of this pull request to the 3.14 branch.

@bedevere-app bedevere-app Bot removed the needs backport to 3.14 bugs and security fixes label Aug 13, 2026
@bedevere-app

bedevere-app Bot commented Aug 13, 2026

Copy link
Copy Markdown

GH-155672 is a backport of this pull request to the 3.15 branch.

@bedevere-app bedevere-app Bot removed the needs backport to 3.15 pre-release feature fixes, bugs and security fixes label Aug 13, 2026
serhiy-storchaka added a commit that referenced this pull request Aug 13, 2026
…k_hostname with CERT_NONE (GH-155509) (GH-155670)

With PROTOCOL_TLS_CLIENT, which became the default protocol in 3.10, this is
an error.  With an explicitly specified legacy protocol it used to succeed,
silently raising verify_mode to CERT_REQUIRED and ignoring the requested
CERT_NONE.

No caller of ssl._create_stdlib_context() in the standard library passes
check_hostname, so no public API reaches it.
(cherry picked from commit 726e485)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
serhiy-storchaka added a commit that referenced this pull request Aug 13, 2026
…k_hostname with CERT_NONE (GH-155509) (GH-155671)

With PROTOCOL_TLS_CLIENT, which became the default protocol in 3.10, this is
an error.  With an explicitly specified legacy protocol it used to succeed,
silently raising verify_mode to CERT_REQUIRED and ignoring the requested
CERT_NONE.

No caller of ssl._create_stdlib_context() in the standard library passes
check_hostname, so no public API reaches it.
(cherry picked from commit 726e485)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
mbeijen pushed a commit to mbeijen/cpython that referenced this pull request Aug 14, 2026
…_hostname with CERT_NONE (pythonGH-155509)

With PROTOCOL_TLS_CLIENT, which became the default protocol in 3.10, this is
an error.  With an explicitly specified legacy protocol it used to succeed,
silently raising verify_mode to CERT_REQUIRED and ignoring the requested
CERT_NONE.

No caller of ssl._create_stdlib_context() in the standard library passes
check_hostname, so no public API reaches it.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

skip news tests Tests in the Lib/test dir

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant