Skip to content

Align SSL APIs and transport behavior with Python 3.15 - #9167

Merged
youknowone merged 1 commit into
RustPython:mainfrom
youknowdot:fix/ssl-315-compatibility
Oct 17, 2026
Merged

youknowone merged 1 commit into
RustPython:mainfrom
youknowdot:fix/ssl-315-compatibility

Conversation

@youknowdot

Copy link
Copy Markdown
Contributor

Summary

  • Refresh Lib/ssl.py and Lib/test/test_ssl.py through the actual updater from CPython d220409a13b77de7a6c30abe16ea90db01528edc. Outputs are byte-identical to canonical source; no test assertions, test bodies, capability guards or certificate fixtures were changed locally.
  • Implement independent TLS 1.3 cipher-suite selection, named groups, server signature policy and negotiated-group reporting for rustls. Preserve certificate, hostname and revocation checks while applying handshake signature restrictions. Improve filename errors, EOF latching and client session policy identity.
  • Keep optional OpenSSL and wasm compatible with the new Python API imports. OpenSSL queries use genuine library enumeration and negotiated state behind the appropriate version gates. Unsupported selected-signature queries on rustls, external PSK and custom-BIO kTLS capabilities are reported honestly.
  • Correct OpenSSL 3 system-error decoding: the locked openssl-sys accessor returns the system-library ID instead of the actual errno. Use its named system-error mask, retain the older-version accessor, and cover ENOENT/EPIPE/ECONNRESET with a pure native regression.
  • Repair OpenSSL prerequisites exposed by canonical coverage: callback pointer/owner/context lifetime and GC traversal, callback exception propagation, scoped SSL access, EOF/error mapping, BIO shutdown, protocol sentinels, certificate filenames and the post-handshake-auth flag. Preserve resumable sessions when native sockets are freed, matching CPython's destructor.

No Cargo/dependency/vendor/parser/test-support migration is included.

Reference behavior and coverage

Known optional-backend limit

The complete OpenSSL suite still cannot finish because the inherited ThreadedTests.test_thread_recv_while_main_thread_sends blocks when a read holds the connection lock and a same-connection writer cannot progress. The test is unchanged. Its initial failed full-suite receipt is retained, and subsequent validation uses the standard runner selector to exclude exactly this known hanging test.

A partial concurrency refactor was investigated but rejected before integration or execution. Correct OpenSSL retry ownership and readiness wakeups require a separate connection-driver change. This PR does not claim full OpenSSL concurrency parity.

Compatibility details

  • Selected-signature results are never guessed. Rustls raises NotImplementedError because its API does not expose the negotiated value.
  • OpenSSL external PSK callbacks previously had a true capability flag but were only stored, never installed into the TLS library. HAS_PSK and HAS_PSK_TLS13 are now false and those setters raise NotImplementedError; full external-PSK implementation is outside this batch.
  • Existing server ticket/store sharing is retained. Bounded MemoryBIO comparisons of rustls and OpenSSL with verified CPython 3.15.0 final confirm TLS 1.2/1.3 parity for unchanged, signature-only and CERT_NONE-to-CERT_REQUIRED context transitions, with real resumed connections and fresh rejecting controls. This is not a general security assertion for every trust or certificate mutation.

Validation

Local checks use base 872030680. Upstream main advanced only by a sha2 lockfile patch while validation ran; hosted merge CI will check that integration.

  • Updater tooling: 70 tests passed; normal source hooks passed.
  • Rustls focused native tests: 8 signature-policy/resumption and 2 error-classification tests passed.
  • Rustls final-source release and complete canonical suite: 215 tests, 40 existing skips passed, without test selection exclusions.
  • OpenSSL 3.5.7 final-source release: the three focused error cases passed, followed by 214 canonical tests with 26 existing skips and the single disclosed duplex exclusion. Final-source distinct/nested/concurrent getter diagnostics also passed. The pure native errno regression passed.
  • OpenSSL 1.1.1w compile-only floor: passed on the final source. This obsolete release was built only in an isolated workspace prefix and is not a recommended runtime.
  • wasm32-unknown-unknown package check: passed on the final source with the verified matching official Rust target component.
  • OpenSSL 3.2/3.3/3.4 gates were source-reviewed; those versions were not independently built or run. LibreSSL/other platform runtime parity is not claimed.
  • Workspace native tests: 1,369 passed across 22 reconciled targets. Separate C-API tests: 123 passed, 4 existing ignores. Workspace and C-API Clippy passed all targets with warnings denied. Workspace doctests: 24 passed, 18 existing ignores; separate C-API doctests completed with none defined.
  • Required hosted merge CI will verify integration with current main after publication.

AI assistance

OpenAI Codex assisted with extracting the migration, implementing the native compatibility and prerequisite fixes, source review, validation, and this description.

Refresh ssl.py and test_ssl.py through update_lib from CPython d220409a13b77de7a6c30abe16ea90db01528edc without local test changes. Implement rustls cipher-suite, group and signature policy, negotiated-group reporting, EOF and session-policy behavior.

Keep OpenSSL and wasm API imports compatible, with genuine version-gated queries and honest unsupported capabilities. Repair OpenSSL callback ownership and traversal, callback exceptions, EOF and shutdown, PHA, session destruction, and system-error decoding exposed by canonical coverage. Preserve existing I/O locking; the inherited optional-backend full-duplex hang remains a separate driver prerequisite.

Assisted-by: OpenAI Codex:model version unavailable
@coderabbitai

coderabbitai Bot commented Oct 16, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

Note

Currently processing new changes in this PR. This may take a few minutes, please wait...

⚙️ Run configuration
  • Configuration used: Repository: RustPython/RustPython/.coderabbit.yml
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: dce8bcec-ab9a-48dc-8ddb-fad273d0b106
📥 Commits

Reviewing files that changed from the base of the PR and between 9a16d28 and d55f258.

⛔ Files ignored due to path filters: 2
  • Lib/ssl.py is excluded by !Lib/**
  • Lib/test/test_ssl.py is excluded by !Lib/**
📒 Files selected for processing: 12
  • crates/host_env/src/ssl/cipher.rs
  • crates/host_env/src/ssl/config.rs
  • crates/host_env/src/ssl/error.rs
  • crates/host_env/src/ssl/handshake.rs
  • crates/host_env/src/ssl/mod.rs
  • crates/host_env/src/ssl/sigalg.rs
  • crates/host_env/src/ssl/verify.rs
  • crates/stdlib/build.rs
  • crates/stdlib/src/openssl.rs
  • crates/stdlib/src/ssl.rs
  • crates/stdlib/src/ssl/compat.rs
  • crates/stdlib/src/ssl_wasm.rs
+-------------------------------------------------------+
| Cancel my subscriptions ... I'm tired of your issues. |
+-------------------------------------------------------+
  \
   \   (\__/)
       (•ㅅ•)
       /   づ
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@github-actions

Copy link
Copy Markdown
Contributor

📦 Library Dependencies

The following Lib/ modules were modified. Here are their dependencies:

:4: SyntaxWarning: invalid decimal literal
:7: SyntaxWarning: "\z" is an invalid escape sequence. Such sequences will not work in the future. Did you mean "\z"? A raw string is also an option.
:10: SyntaxWarning: "\400" is an invalid octal escape sequence. Such sequences will not work in the future. Did you mean "\400"? A raw string is also an option.
:4: SyntaxWarning: invalid decimal literal
:7: SyntaxWarning: "\z" is an invalid escape sequence. Such sequences will not work in the future. Did you mean "\z"? A raw string is also an option.
:10: SyntaxWarning: "\400" is an invalid octal escape sequence. Such sequences will not work in the future. Did you mean "\400"? A raw string is also an option.
:4: SyntaxWarning: invalid decimal literal
:7: SyntaxWarning: "\z" is an invalid escape sequence. Such sequences will not work in the future. Did you mean "\z"? A raw string is also an option.
:10: SyntaxWarning: "\400" is an invalid octal escape sequence. Such sequences will not work in the future. Did you mean "\400"? A raw string is also an option.
[x] lib: cpython/Lib/ssl.py
[x] test: cpython/Lib/test/test_ssl.py

dependencies:

  • ssl

dependent tests: (55 tests)

  • ssl: test_asyncio test_ftplib test_httplib test_httpservers test_imaplib test_logging test_poplib test_ssl test_urllib test_urllib2_localnet test_venv test_xmlrpc
    • asyncio.selector_events: test_asyncio
    • ftplib: test_urllib2
      • urllib.request: test_http_cookiejar test_pathlib test_pydoc test_sax test_site test_urllib2net test_urllibnet
    • http.client: test_docxmlrpc test_hashlib test_ucn test_unicodedata test_wsgiref
      • logging.handlers: test_concurrent_futures test_pkgutil
    • http.server: test_robotparser
      • pydoc: test_enum
    • smtplib: test_smtplib test_smtpnet
    • urllib.request:
      • pathlib: test_ast test_dbm_sqlite3 test_ensurepip test_importlib test_json test_launcher test_netrc test_os test_pathlib test_peg_generator test_pyrepl test_runpy test_tarfile test_tempfile test_tomllib test_tools test_traceback test_unparse test_winapi test_zipapp test_zipfile test_zoneinfo test_zstd

Legend:

  • [+] path exists in CPython
  • [x] up-to-date, [ ] outdated

@youknowone
youknowone marked this pull request as ready for review October 17, 2026 02:34
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 17, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ⚠️ Failed 2026-10-17T02:42:24.432266Z d55f258 Draft marked ready
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@youknowone
youknowone merged commit fb76135 into RustPython:main Oct 17, 2026
30 of 31 checks passed
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