René's URL Explorer Experiment


Title: `ssl.HAS_TLSv1_2` is `False` with OpenSSL 4.0 although TLS 1.2 connections work · Issue #159387 · python/cpython · GitHub

Open Graph Title: `ssl.HAS_TLSv1_2` is `False` with OpenSSL 4.0 although TLS 1.2 connections work · Issue #159387 · python/cpython

X Title: `ssl.HAS_TLSv1_2` is `False` with OpenSSL 4.0 although TLS 1.2 connections work · Issue #159387 · python/cpython

Description: Bug report Summary When _ssl is built against OpenSSL 4.0, ssl.HAS_TLSv1_2 is False, yet a context limited to maximum_version = TLSVersion.TLSv1_2 negotiates a TLS 1.2 connection. The same compile-time condition makes _ssl treat TLS 1.3 ...

Open Graph Description: Bug report Summary When _ssl is built against OpenSSL 4.0, ssl.HAS_TLSv1_2 is False, yet a context limited to maximum_version = TLSVersion.TLSv1_2 negotiates a TLS 1.2 connection. The same compile-...

X Description: Bug report Summary When _ssl is built against OpenSSL 4.0, ssl.HAS_TLSv1_2 is False, yet a context limited to maximum_version = TLSVersion.TLSv1_2 negotiates a TLS 1.2 connection. The same compile-...

Opengraph URL: https://github.com/python/cpython/issues/159387

X: @github

direct link

Domain: github.com


Hey, it has json ld scripts:
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"`ssl.HAS_TLSv1_2` is `False` with OpenSSL 4.0 although TLS 1.2 connections work","articleBody":"### Bug report\n\n### Summary\n\nWhen `_ssl` is built against OpenSSL 4.0, `ssl.HAS_TLSv1_2` is `False`, yet a context limited to `maximum_version = TLSVersion.TLSv1_2` negotiates a TLS 1.2 connection. The same compile-time condition makes `_ssl` treat TLS 1.3 as the minimum available protocol. As a result, `TLSVersion.MINIMUM_SUPPORTED` resolves to TLS 1.3, and `test_ssl` skips its TLS 1.2 tests.\n\n### Reproduction\n\n\n```python\nimport os, socket, ssl, threading\nimport test\n\nprint(ssl.OPENSSL_VERSION)\nprint(\"HAS_TLSv1_2:\", ssl.HAS_TLSv1_2)\n\ncertfile = os.path.join(os.path.dirname(test.__file__), \"certdata\", \"keycert.pem\")\nserver_ctx = ssl.SSLContext(ssl.PROTOCOL_TLS_SERVER)\nserver_ctx.load_cert_chain(certfile)\nserver_ctx.maximum_version = ssl.TLSVersion.TLSv1_2\n\nclient_ctx = ssl.SSLContext(ssl.PROTOCOL_TLS_CLIENT)\nclient_ctx.check_hostname = False\nclient_ctx.verify_mode = ssl.CERT_NONE\nclient_ctx.maximum_version = ssl.TLSVersion.TLSv1_2\n\nlistener = socket.create_server((\"127.0.0.1\", 0))\n\ndef serve():\n    conn, _ = listener.accept()\n    with server_ctx.wrap_socket(conn, server_side=True) as s:\n        s.recv(1)\n\nt = threading.Thread(target=serve)\nt.start()\nwith client_ctx.wrap_socket(socket.create_connection(listener.getsockname())) as s:\n    print(\"negotiated:\", s.version(), s.cipher())\n    s.send(b\"x\")\nt.join()\nlistener.close()\n\nctx = ssl.SSLContext(ssl.PROTOCOL_TLS_CLIENT)\nctx.maximum_version = ssl.TLSVersion.MINIMUM_SUPPORTED\nprint(\"maximum_version = MINIMUM_SUPPORTED ->\", repr(ctx.maximum_version))\n```\n\n```bash\n./python -m test test_ssl -v -m test_psk -m test_min_max_version_tlsv1_2 \\\n    -m test_min_max_version_mismatch -m test_protocol_tlsv1_2\n```\n\n### Actual Behavior\n\n```\nOpenSSL 4.0.2 25 Aug 2026\nHAS_TLSv1_2: False\nnegotiated: TLSv1.2 ('ECDHE-RSA-AES256-GCM-SHA384', 'TLSv1.2', 256)\nmaximum_version = MINIMUM_SUPPORTED -> \u003cTLSVersion.TLSv1_3: 772>\n```\n\n```\ntest_min_max_version_mismatch (test.test_ssl.ThreadedTests.test_min_max_version_mismatch) ... skipped 'TLSv1_2 is not available.'\ntest_min_max_version_tlsv1_2 (test.test_ssl.ThreadedTests.test_min_max_version_tlsv1_2) ... skipped 'TLSv1_2 is not available.'\nConnecting to a TLSv1.2 server with various client options. ... skipped 'TLSv1_2 is not available.'\ntest_psk (test.test_ssl.ThreadedTests.test_psk) ... skipped 'TLSv1_2 is not available.'\n```\n\n### Expected Behavior\n\nThe `ssl` documentation defines `HAS_TLSv1_2` as \"Whether the OpenSSL library has built-in support for the TLS 1.2 protocol.\" OpenSSL 4.0.2 still supports TLS 1.2: the handshake above succeeds, and `openssl ciphers -s -tls1_2` lists TLS 1.2 cipher suites such as `ECDHE-ECDSA-AES256-GCM-SHA384`. So `HAS_TLSv1_2` should be `True`. `TLSVersion.MINIMUM_SUPPORTED` should map to a version no higher than TLS 1.2, and the TLS 1.2 tests in `test_ssl` should run instead of being skipped.\n\n#### Root cause\n\n`Modules/_ssl.c` contains this block, added for OpenSSL 4.0 in gh-146207:\n\n```c\n#if (OPENSSL_VERSION_NUMBER >= 0x40000000L)\n#  define OPENSSL_NO_SSL3\n#  define OPENSSL_NO_TLS1\n#  define OPENSSL_NO_TLS1_1\n#  define OPENSSL_NO_TLS1_2\n#  define OPENSSL_NO_SSL3_METHOD\n#  define OPENSSL_NO_TLS1_METHOD\n#  define OPENSSL_NO_TLS1_1_METHOD\n#  define OPENSSL_NO_TLS1_2_METHOD\n#endif\n```\n\nThe OpenSSL 4.0 compatibility block mixes up protocol availability with fixed-version method availability.\n\nOPENSSL_NO_TLS1_2_METHOD means TLSv1_2_method() is unavailable, while OPENSSL_NO_TLS1_2 means the TLS 1.2 protocol itself is unavailable. OpenSSL 4.0 removed the deprecated fixed-version methods, but TLS 1.0, 1.1 and 1.2 remain usable through TLS_method().\n\nBecause _ssl.c defines the protocol-level macros as well, CPython treats TLS 1.0–1.2 as unavailable. This makes ssl.HAS_TLSv1_2 false, causes TLSVersion.MINIMUM_SUPPORTED to resolve to TLS 1.3, and makes TLS 1.2 tests guarded by requires_tls_version() get skipped, even though a TLS 1.2 handshake succeeds.\n\n\n### CPython versions tested on:\n\nCPython main branch\n\n### Operating systems tested on:\n\nLinux\n\n\u003c!-- gh-linked-prs -->\n### Linked PRs\n* gh-159388\n* gh-161320\n\u003c!-- /gh-linked-prs -->\n","author":{"url":"https://github.com/lpyu001","@type":"Person","name":"lpyu001"},"datePublished":"2026-10-14T02:13:08Z","url":"https://github.com/python/cpython/issues/159387"}

react-profiling0
react-import-mapreact,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322
route-pattern/_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format)
route-controllervoltron_issues_fragments
route-actionissue_layout
fetch-noncev2:8d7b6d12-f1d4-7138-2620-2c56e1bc5218
current-catalog-service-hash81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114
request-idDB16:22DB35:471B82C:5A84AF6:6B023346
html-safe-nonce1542d01580af1bc0c30109ba6603ddb635e0f625720ad12f2cb371e4fb5ea3e9
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJEQjE2OjIyREIzNTo0NzFCODJDOjVBODRBRjY6NkIwMjMzNDYiLCJ2aXNpdG9yX2lkIjoiNDQ5NDg1MzY5NzA2NjY0NDI5NCIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9
visitor-hmacf412c1dddd83383609bc74a1676d714dcf9a6e30790073df68004621ed170f04
hovercard-subject-tagissue:5840751164
github-keyboard-shortcutsrepository,issues,copilot
google-site-verificationApib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I
octolytics-urlhttps://collector.github.com/github/collect
analytics-location///voltron/issues_fragments/issue_layout
fb:app_id1401488693436528
apple-itunes-appapp-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/python/cpython/159387/issue_layout
twitter:imagehttps://opengraph.githubassets.com/95b9349dc397f3a9ff5a43876e57e36ef4dae151975fc2c7ff9071a777ce0ce3/python/cpython/issues/159387
twitter:cardsummary_large_image
og:imagehttps://opengraph.githubassets.com/95b9349dc397f3a9ff5a43876e57e36ef4dae151975fc2c7ff9071a777ce0ce3/python/cpython/issues/159387
og:image:altBug report Summary When _ssl is built against OpenSSL 4.0, ssl.HAS_TLSv1_2 is False, yet a context limited to maximum_version = TLSVersion.TLSv1_2 negotiates a TLS 1.2 connection. The same compile-...
og:image:width1200
og:image:height600
og:site_nameGitHub
og:typeobject
og:author:usernamelpyu001
hostnamegithub.com
expected-hostnamegithub.com
None87e774ee7c6b3bee0490394e4d3e57ec9dbc956f74b87ea685dc8996c1676456
turbo-cache-controlno-preview
go-importgithub.com/python/cpython git https://github.com/python/cpython.git
octolytics-dimension-user_id1525981
octolytics-dimension-user_loginpython
octolytics-dimension-repository_id81598961
octolytics-dimension-repository_nwopython/cpython
octolytics-dimension-repository_publictrue
octolytics-dimension-repository_is_forkfalse
octolytics-dimension-repository_network_root_id81598961
octolytics-dimension-repository_network_root_nwopython/cpython
turbo-body-classeslogged-out env-production page-responsive
disable-turbofalse
browser-stats-urlhttps://api.github.com/_private/browser/stats
browser-errors-urlhttps://api.github.com/_private/browser/errors
release423dbb54c5e7bfecc838eb387c1435eb3d0e760d
ui-targetfull
theme-color#1e2327
color-schemelight dark
react-app-nameissues

Links:

Skip to contenthttps://github.com/python/cpython/issues/159387#start-of-content
https://github.com/
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fpython%2Fcpython%2Fissues%2F159387
GitHubRepository hosting, code review, and collaborationhttps://github.com/platform
CopilotAI coding agent for tasks, projects, and automated workhttps://github.com/features/copilot
ActionsCI/CD and automationhttps://github.com/features/actions
Code QualityQuality analysis, fixes, and enforcementhttps://github.com/features/code-quality
CodespacesCloud development environmentshttps://github.com/features/codespaces
Code SecurityVulnerability detection and remediationhttps://github.com/security/advanced-security/code-security
Secret ProtectionSecret scanning and leak preventionhttps://github.com/security/advanced-security/secret-protection
All Featureshttps://github.com/features
Documentationhttps://docs.github.com/en
Traininghttps://learn.github.com/skills
Certificationshttps://learn.github.com/credentials
Build with Copilothttps://github.com/features/ai
Customize Copilothttps://docs.github.com/en/copilot/how-tos/copilot-on-github/customize-copilot/customize-copilot-overview
Integrationshttps://github.com/marketplace
Trending reposhttps://github.com/trending
GitHub Sponsorshttps://github.com/open-source/sponsors
Developer articleshttps://github.com/resources/articles
ChangelogYour source for the latest features, improvements, and fixes across GitHub products, all in one place.https://github.blog/changelog/
Enterpriseshttps://github.com/enterprise
Teamhttps://github.com/team
Startupshttps://github.com/enterprise/startups
Nonprofitshttps://github.com/solutions/industry/nonprofits
Healthcarehttps://github.com/solutions/industry/healthcare
Financial serviceshttps://github.com/solutions/industry/financial-services
Manufacturinghttps://github.com/solutions/industry/manufacturing
Governmenthttps://github.com/solutions/industry/government
See all industrieshttps://github.com/solutions/industry
Why GitHubhttps://github.com/why-github
Customer Storieshttps://github.com/customer-stories
Business insightshttps://github.com/solutions/executive-insights
Trust Centerhttps://github.com/trust-center
GitHub Advanced SecurityEnterprise-grade code securityhttps://github.com/security/advanced-security
Copilot for businessEnterprise-grade AI featureshttps://github.com/features/copilot/copilot-business
Premium SupportEnterprise-grade 24/7 supporthttps://github.com/enterprise/premium-support
Documentationhttps://docs.github.com/en
Resource centerhttps://github.com/resources
Bloghttps://github.blog/
Events & webinarshttps://github.com/resources/events
Community Forumhttps://github.com/orgs/community/discussions
Customer Storieshttps://github.com/customer-stories
Integrationshttps://github.com/marketplace
Customer supporthttps://help.github.com/
Traininghttps://learn.github.com/skills
GitHub Statushttps://www.githubstatus.com/
Abouthttps://github.com/about
Partnershttps://github.com/partners
Changeloghttps://github.blog/changelog/
GitHub UniverseThe event for developers, by developers — talks, workshops, and what’s next for GitHub.https://githubuniverse.com/
Pricinghttps://github.com/pricing
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fpython%2Fcpython%2Fissues%2F159387
Sign uphttps://github.com/signup?ref_cta=Sign+up&ref_loc=header+logged+out&ref_page=%2F%3Cuser-name%3E%2F%3Crepo-name%3E%2Fvoltron%2Fissues_fragments%2Fissue_layout&source=header-repo&source_repo=python%2Fcpython
Reloadhttps://github.com/python/cpython/issues/159387
Reloadhttps://github.com/python/cpython/issues/159387
Reloadhttps://github.com/python/cpython/issues/159387
pythonhttps://github.com/python
cpythonhttps://github.com/python/cpython
Codehttps://github.com/python/cpython
Issues5k+ (5k+)https://github.com/python/cpython/issues
Pull requests2.4k (2.4k)https://github.com/python/cpython/pulls
Actionshttps://github.com/python/cpython/actions
Projectshttps://github.com/python/cpython/projects
Security and qualityhttps://github.com/python/cpython/security
Insightshttps://github.com/python/cpython/insights
https://github.com/python/cpython
New issuehttps://github.com/login?return_to=https://github.com/python/cpython/issues/159387
New issuehttps://github.com/login?return_to=https://github.com/python/cpython/issues/159387
ssl.HAS_TLSv1_2 is False with OpenSSL 4.0 although TLS 1.2 connections workhttps://github.com/python/cpython/issues/159387#top
extension-modulesC modules in the Modules dirhttps://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%22extension-modules%22
topic-SSLhttps://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%22topic-SSL%22
type-bugAn unexpected behavior, bug, or errorhttps://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%22type-bug%22
https://github.com/lpyu001
lpyu001https://github.com/lpyu001
on Oct 14, 2026https://github.com/python/cpython/issues/159387#issue-5840751164
gh-146207https://github.com/python/cpython/issues/146207
gh-159387: Fix TLS 1.0–1.2 availability detection with OpenSSL 4.0 #159388https://github.com/python/cpython/pull/159388
[3.15] gh-159387: Fix TLS 1.0–1.2 availability detection with OpenSSL 4.0 (GH-159388) #161320https://github.com/python/cpython/pull/161320
lpyu001https://github.com/lpyu001
type-bugAn unexpected behavior, bug, or errorhttps://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%22type-bug%22
on Oct 14, 2026https://github.com/python/cpython/issues/159387#event-33188092037
aiskhttps://github.com/aisk
topic-SSLhttps://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%22topic-SSL%22
on Oct 14, 2026https://github.com/python/cpython/issues/159387#event-33191878844
picnixzhttps://github.com/picnixz
extension-modulesC modules in the Modules dirhttps://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%22extension-modules%22
on Oct 14, 2026https://github.com/python/cpython/issues/159387#event-33231084666
https://github.com/lpyu001
lpyu001https://github.com/lpyu001
on Oct 18, 2026https://github.com/python/cpython/issues/159387#issuecomment-6247633032
@vstinnerhttps://github.com/vstinner
kevinprimeraquecreo-stackhttps://github.com/kevinprimeraquecreo-stack
Project_VKhttps://github.com/users/kevinprimeraquecreo-stack/projects/1
on Oct 18, 2026https://github.com/python/cpython/issues/159387#event-33592165265
github-project-automationhttps://github.com/apps/github-project-automation
Project_VKhttps://github.com/users/kevinprimeraquecreo-stack/projects/1
on Oct 18, 2026https://github.com/python/cpython/issues/159387
kevinprimeraquecreo-stackhttps://github.com/kevinprimeraquecreo-stack
Project_VKhttps://github.com/users/kevinprimeraquecreo-stack/projects/1
on Oct 18, 2026https://github.com/python/cpython/issues/159387#event-33592181245
gpsheadhttps://github.com/gpshead
on Oct 31, 2026https://github.com/python/cpython/issues/159387#event-34803456025
gh-159387: Fix TLS 1.0–1.2 availability detection with OpenSSL 4.0 (G…https://github.com/python/cpython/commit/e7acd6a82f2feec196b84fdfc1d1533e37024221
gh-159387https://github.com/python/cpython/issues/159387
G…https://github.com/python/cpython/pull/159388
e7acd6ahttps://github.com/python/cpython/commit/e7acd6a82f2feec196b84fdfc1d1533e37024221
lpyu001https://github.com/lpyu001
completedhttps://github.com/python/cpython/issues?q=is%3Aissue%20state%3Aclosed%20archived%3Afalse%20reason%3Acompleted
on Nov 1, 2026https://github.com/python/cpython/issues/159387#event-34823686903
vstinnerhttps://github.com/vstinner
on Nov 6, 2026https://github.com/python/cpython/issues/159387#event-35352139090
[3.15] gh-159387: Fix TLS 1.0–1.2 availability detection with OpenSSL…https://github.com/python/cpython/commit/3e87c6315efb7593f97fc36a0fdf7a87e60ed90b
gh-159387https://github.com/python/cpython/issues/159387
3e87c63https://github.com/python/cpython/commit/3e87c6315efb7593f97fc36a0fdf7a87e60ed90b
mehwhttps://github.com/mehw
on Nov 6, 2026https://github.com/python/cpython/issues/159387#event-35388662623
Fix compiling Python 2.7.18 with OpenSSL 4https://github.com/mehw/cpython/commit/5a2dd8edf88ab81dd76182ca0aade8f96fca56af
5a2dd8ehttps://github.com/mehw/cpython/commit/5a2dd8edf88ab81dd76182ca0aade8f96fca56af
SquallATFhttps://github.com/SquallATF
on Nov 16, 2026https://github.com/python/cpython/issues/159387#event-36229487405
pythongh-159387: Fix TLS 1.0–1.2 availability detection with OpenSSL …https://github.com/SquallATF/cpython-mingw/commit/66745bc8084f93ae89e8f1635f9f33d8236ad826
pythongh-159387https://github.com/python/cpython/issues/159387
66745bchttps://github.com/SquallATF/cpython-mingw/commit/66745bc8084f93ae89e8f1635f9f33d8236ad826
Sign up for freehttps://github.com/signup?return_to=https://github.com/python/cpython/issues/159387
Sign in to commenthttps://github.com/login?return_to=https://github.com/python/cpython/issues/159387
extension-modulesC modules in the Modules dirhttps://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%22extension-modules%22
topic-SSLhttps://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%22topic-SSL%22
type-bugAn unexpected behavior, bug, or errorhttps://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%22type-bug%22
https://github.com
Termshttps://docs.github.com/site-policy/github-terms/github-terms-of-service
Privacyhttps://docs.github.com/site-policy/privacy-policies/github-privacy-statement
Securityhttps://github.com/security
Statushttps://www.githubstatus.com/
Communityhttps://github.community/
Docshttps://docs.github.com/
Contacthttps://support.github.com?tags=dotcom-footer

Viewport: width=device-width


URLs of crawlers that visited me.