Skip to content

Merge rustls 0.23.46 and make the crate publishable as shaped-rustls - #2

Merged
aimalygin merged 110 commits into
xray/rustls-0.23.40from
claude/publish-shaped-rustls
Nov 20, 2026
Merged

aimalygin merged 110 commits into
xray/rustls-0.23.40from
claude/publish-shaped-rustls

Conversation

@aimalygin

@aimalygin aimalygin commented Nov 20, 2026 •

Copy link
Copy Markdown
Owner

Brings the branch from rustls 0.23.40 to 0.23.46 and makes the crate publishable on crates.io under its own name. Nothing is published by this PR.

Merge with a merge commit, not squash or rebase: the first commit is a merge of the upstream tag, and the next merge of upstream needs that ancestry.

Commits

  1. Merge rustls 0.23.46 (2f6b6ed). Carries upstream's fixes for RUSTSEC-2026-0285, -0346, -0348 and -0349. Conflicts were in Cargo.lock and in four places of rustls/src/client/hs.rs:

    • the config's version and cipher suite lookups take the protocol now, so the planned and default supported versions take it too;
    • upstream now keeps the offered cipher suites in the hello details and checks a ServerHello against them; the branch's own copy of that list is removed, and the check of a HelloRetryRequest's suite reads upstream's field;
    • raw extensions still count as sent.

    Two adaptations outside the conflicts: an extension plan can disable the new ticket_request extension (RFC 9149), and upstream's new ECH test builds its supported versions through the constructor, because this branch made the struct's fields private.

  2. client tests: pin the certificate decompressors where the extension list is exact (422ef19). Seven shaping tests compare the emitted extensions with a fixed list that has no compress_certificate. With the brotli or zlib feature the default config offers it, so they failed on the order check, on this branch before the merge as well (14 failures: seven tests, two providers).

  3. Publish the crate as shaped-rustls 0.23.4600 (b2f2ab8). The rename, the manifests that name the package, the README's own section, and a workflow for this fork's branches.

After the first CI run on this PR (see below):

  1. client: clear what Clippy reports in the shaping code (e98ce82). Nine lints, no behaviour change.
  2. client tests: leave the X25519 key share tests out under FIPS (9bdd54f). The FIPS provider offers no X25519 key share.
  3. Say where the fork differs from upstream without a customizer (b305afc). rust-version is 1.85, and the README names the two differences listed under "Decisions".
  4. ci: follow the package rename and the new minimum Rust (57671f8). Upstream's workflows named the package rustls in twelve places; the MSRV job uses 1.85; CIFuzz runs for the upstream repository only; fuzz/Cargo.lock follows the rename.
  5. Cargo.lock: take the fixed releases of crates with advisories (ca6bc0f). rustls-webpki, webpki-roots, tokio and the three hickory crates. crypto-bigint 0.5.5, a dependency of the provider example, has no compatible fixed release and stays.

After the second CI run:

  1. ci: finish the move to Rust 1.85 (0caf7f8). The MSRV job's second step installs 1.85; rustls/.clippy.toml pins Clippy's msrv to upstream's 1.71, so that Clippy does not ask to rewrite upstream's code for the newer version; RUSTSEC-2026-0387 (crypto-bigint, through the provider example and the ECH test dependencies) joins deny.toml's ignore list; the manifest's homepage, which repeated repository, is removed.

After the third CI run:

  1. Clippy: the shaping tests and the bench (e27b66f). The shaping tests use the crate's sync::Arc instead of std::sync::Arc, which rustls/.clippy.toml disallows (86 places), and struct initializers where five of them filled a default value field by field. admin/clippy lints rustls-bench with every feature except graviola: rustls-graviola is built against upstream's rustls package, whose types are not this crate's now that the workspace [patch] entry is gone.

After the fourth CI run:

  1. ci: compare the API only once there is a release to compare with (6cf504a). The semver job asks crates.io for the crate first: found, the check runs as upstream's does; not found, it is skipped; any other answer fails the job.

Decisions

Confirmed by the owner:

  • Package shaped-rustls, library rustls. Code written for rustls compiles unchanged with rustls = { package = "shaped-rustls", version = "0.23.4600" }. Renaming the library as well would touch every doctest, example and test of upstream and make each later merge harder.
  • Versions 0.23.PPRR: upstream patch PP, fork release RR. 0.23.4600 is the first release on rustls 0.23.46, a fork-only fix would be 0.23.4601, a move to rustls 0.23.47 would be 0.23.4700. A ^0.23 requirement follows both.

Still to look at in review:

  • [patch.crates-io] entry and tokio-rustls-smoke removed. A package of another name cannot stand in for rustls under [patch], and the smoke crate tested exactly that. tokio-rustls, quinn and the like keep upstream rustls; a shaped hello under them needs an adapter built against this crate.
  • Minimum Rust 1.85, where upstream has 1.71. The aws_lc_rs feature, on by default, has depended on the shake crate (edition 2024) since this branch added it; the manifest's 1.71 was not true of a default build.
  • Unknown extensions in a TLS 1.3 certificate entry are ignored, with or without a customizer, where upstream rejects the message. That is this branch's behaviour since 94f088e and what Go's crypto/tls does; this PR does not change it. It documents it in the README and disables the one BoGo test that expects the rejection, SendUnknownExtensionOnCertificate-TLS13. Ignoring only what the hello itself offered would keep the default path as strict as upstream; that is a change to the handshake parsing and is not part of this PR.

First CI run (on b2f2ab8)

  • shaped-rustls workflow: 3 of 3 jobs passed.
  • Upstream's rustls workflow: 7 passed, 10 failed, 11 were cancelled after those. The failures and what commits 4 to 8 do about them:
    • docs, MSRV and the cross-target jobs named the package rustls: fixed in 7;
    • Build+test, Features and coverage ran with the fips feature and failed three shaping tests: 5;
    • Clippy: 4;
    • MSRV also could not parse the lockfile's edition-2024 crates on Rust 1.71: 6 and 7;
    • BoGo failed one test, SendUnknownExtensionOnCertificate-TLS13, and passed the rest: 6;
    • audit reported advisories against lockfile entries: 8, except crypto-bigint;
    • the semver check needs the crate on crates.io and will fail until the first release.
  • CIFuzz cannot work outside the upstream repository: 7.

Second CI run (on ca6bc0f)

  • shaped-rustls workflow: 3 of 3 passed.
  • Upstream's rustls workflow: BoGo, Features (with FIPS), docs, coverage and the cross-target job that had finished all passed. Red: MSRV, Clippy and audit, which commit 9 addresses, and the semver check, which stays red until the crate has a release on crates.io. The Windows and macOS Build+test jobs were still running when this was read.

Third CI run (on 0caf7f8)

Everything passed, the Windows and macOS Build+test jobs, MSRV and audit included, except Clippy, which commit 10 addresses, and the semver check, which stays red until the crate has a release on crates.io.

After commit 10, locally: Clippy 1.96 over all twelve workspace members with their default features and all targets is clean (with -A clippy::nonminimal_bool for the two findings in upstream's server code that only this local version reports), and the ring and ring,brotli,zlib tests pass (1096 and 1106). The all-features variants need FIPS and were not run locally.

Fourth CI run (on e27b66f)

Clippy, MSRV, audit, BoGo, Features and the Linux builds passed. Two jobs were not green, neither for the code: the semver check, which had no release to compare with (commit 11), and the macOS Build+test job, which GitHub cancelled after fifteen minutes without a runner, before any step ran; the same job had passed on 0caf7f8. Windows was still running when this was read.

The script of commit 11's new step was run locally: crates.io answers 404 for shaped-rustls and 200 for rustls.

Verification

All local, with rustc 1.96 on macOS arm64. The first seven items were run on ca6bc0f; commit 9 touches no Rust source, and after it the formatting check, the ring,brotli,zlib tests (1106 passed), Clippy for the provider-test package (the step that failed in CI, reproduced before the fix) and the publish dry run were repeated. cargo-deny was not run locally.

  • cargo fmt --all -- --check and cargo check --workspace --all-targets --locked: pass.
  • cargo test --locked -p shaped-rustls --features ring: 1096 passed, 0 failed, 8 ignored.
  • cargo test --locked -p shaped-rustls --features ring,brotli,zlib: 1106 passed, 0 failed, 8 ignored.
  • cargo test --locked -p shaped-rustls --no-default-features --features tls12,std: 165 passed, 0 failed, 8 ignored.
  • cargo clippy --locked --package shaped-rustls --features ring,brotli,zlib --all-targets -- --deny warnings with Clippy 1.96: clean in the fork's code; it reports two lints in upstream's server/hs.rs and server/tls13.rs, which the CI's Clippy did not report and which are left alone.
  • admin/check-clienthello-compat: the default ClientHello equals upstream 0.23.46's in all four cases (ring and aws-lc-rs, with and without TLS 1.2).
  • cargo publish --locked -p shaped-rustls --dry-run: packages 121 files and builds the packaged crate.
  • xray-rust at its current main with its [patch] pointed at this tree (package name set back to rustls for the run): the uTLS byte oracles and shaping tests pass unchanged (chrome_parrot 3, reality_clienthello 14, reality_rustls 12, shaped_rustls 1, utls_hello_retry 3, utls_tls_shaping 45) and so do the 787 library tests of xray-transport.

Not run locally: the fips feature (needs cmake), the BoGo and OpenSSL suites, the fuzz targets, Linux and Windows. This PR's CI covers them.

After the merge

  • Tag the merge and publish, by the owner's word and with the owner's crates.io login.
  • xray-rust re-vendors from the merged revision, which reduces its local patch to the manifest rewrite.

🤖 Generated with Claude Code

djc and others added 30 commits June 22, 2026 13:16
This test was only fetching ECH config data from DNS and then checking
we could unmarshal it. The daily tests CI is now configured to use the
full-fledged ech-example.rs binary for the same test sites. Doing that
_also_ tests the DNS ECH config list handling, but goes further and uses
the unmarshalled configs for a real ECH enabled handshake. We can delete
these tests on the back of that improved end-to-end coverage.
The libcrux crates have fixed this upstream but a release may not be
available for some time. Ignore the unmaintained transitive dep warning
for now.
Add a `max_tls13_tickets` field to `ServerConfig` that caps the number
of tickets the server will send in response to a client ticket_request
extension. Defaults to 0 (disabled), preserving current behavior.

This is the backwards-compatible equivalent of the `Tls13Tickets`
struct on `main`.
Allow a TLS 1.3 client to request a specific number of session tickets
via the ticket_request extension, and let the server honor that request
up to its configured max_tls13_tickets.

The client sends new_session_count/resumption_count in its ClientHello
(configured via ClientConfig::send_ticket_request); the server replies
with the expected count in EncryptedExtensions and sends
min(requested, max_tls13_tickets) NewSessionTicket messages.

Backport of the feature from main, adapted for the rel-0.23 API surface.
Test/example code only; fixed on main by dropping the dependency.
On Unix, open the key log with mode 0o600 so a typical umask does not
leave traffic secrets world-readable. Existing files are left unchanged.
djc and others added 29 commits October 13, 2026 09:44
RFC 9849 section 6.1.4 makes a HelloRetryRequest's ECH decision final:
section 6.1.5 requires the ServerHello to confirm an acceptance again
(else illegal_parameter), and section 6.1.6 continues with the outer
hello after a rejection. The client decided afresh from the ServerHello,
so a missing confirmation after an accepting HelloRetryRequest became a
rejection, and a confirmation after a rejecting one revived the offer.
Record the decision in EchState and hold the ServerHello to it.
Previously, only the record at exactly the limit was caught. Alerts are
encrypted without checking the limit, so in TLS 1.2 a warning alert
(such as the no_renegotiation alert sent in response to a HelloRequest)
could take that slot, after which application data would continue to be
encrypted with the exhausted key.
Previously, the limit was checked for each fragment in turn, so a write
crossing the limit in TLS 1.2 would send a prefix of its data followed
by close_notify. A peer that treats close_notify as the end of the data
could then accept the truncated data as complete.
The AEAD nonce sequence was incremented before authentication, so a
rejected ciphertext consumed sequence zero and the retry failed.
Previously, a key update was only sent after an entire write had been
encrypted, so a write spanning the confidentiality limit kept encrypting
records under the exhausted keys. Instead, stop before the record that
would take the last sequence number allowed by the current keys, send
the key update request with that sequence number, and continue the write
under the new keys.

This is a targeted backport of the fix for rustls#3302 from rustls#3342.
Previously, when a call to `WriteTraffic::encrypt()` reached the
confidentiality limit of the traffic keys, the key update was only sent
at the start of the next call, so the current keys were used for more
records than allowed. Instead, request the key update before encrypting
application data that would take the last sequence number allowed by the
current keys, so that the key update takes that sequence number.

Like the previous commit, this addresses rustls#3302 for the unbuffered API.
Like the client session types, this avoids printing the master secret.
Brings the branch from rustls 0.23.40 to 0.23.46, which carries the fixes for
RUSTSEC-2026-0285, -0346, -0348 and -0349.

Conflicts were in Cargo.lock (upstream's, then regenerated) and in
rustls/src/client/hs.rs:

- the config's version and cipher suite lookups take the protocol now, so the
  planned and default supported versions take it too;
- upstream keeps the offered cipher suites in the hello details and checks a
  ServerHello against them; the branch's own copy of that list is gone, and
  the check of a HelloRetryRequest's suite reads upstream's field;
- raw extensions still count as sent.

Two adaptations outside the conflicts: an extension plan can disable the new
ticket_request extension (RFC 9149), and upstream's new ECH test builds its
supported versions through the constructor, since the branch made the
struct's fields private.

No ClientHello byte changes: the shaping tests of this crate and the uTLS
byte oracles of xray-rust pass unchanged.
…ist is exact

Seven shaping tests compare the emitted extensions with a fixed list that has
no compress_certificate. With the brotli or zlib feature the default config
offers it, and the tests failed on the order check before any shaping was
compared. They now clear the config's decompressors, as their neighbours do.
The package is renamed from `rustls` to `shaped-rustls` so that it can go to
crates.io beside upstream. Its library keeps the name `rustls`: code written
for rustls compiles against it with one line in the manifest,
`rustls = { package = "shaped-rustls", version = "0.23.4600" }`.

A version is `0.23.PPRR`, upstream patch `PP` and fork release `RR`, so a
`^0.23` requirement follows both a fork fix and a rebase onto the next
upstream patch.

- every manifest of the workspace that takes the crate by path names the
  package;
- the `[patch.crates-io]` entry that put the local crate under third-party
  crates is gone: a package of another name cannot stand in for `rustls`.
  With it goes `tokio-rustls-smoke`, which tested exactly that. tokio-rustls,
  quinn and the like keep upstream rustls; a shaped hello under them needs an
  adapter built against this crate;
- `admin/check-clienthello-compat` derives the upstream tag from the new
  version scheme and builds its harness against the renamed package;
  `admin/clippy` and `admin/coverage` name the package;
- the README's own section says what the fork is, how to depend on it, how
  it is versioned and that RustSec advisories for rustls are not matched to
  it;
- `.github/workflows/shaped.yml` tests the crate with `ring` and with
  `ring,brotli,zlib` and builds the package on the `shaped/**` and `xray/**`
  branches.
No behaviour change. The planned key share group is the plan's first supported
group, said as that instead of a loop that broke after one turn; positioned
GREASE extensions are merged by iterating the real order; four error strings
lose a no-op conversion; the GREASE ECH arm carries its condition as a guard;
an unneeded pattern and an unneeded borrow go.
The FIPS provider offers no X25519 key share, so with the fips feature two
shaping tests that plan one stopped at 'ClientHello key share group is not
supported by this config' before comparing anything.
- rust-version is 1.85, not 1.71: the aws_lc_rs feature, on by default,
  depends on the shake crate (edition 2024, Rust 1.85). The manifest said 1.71
  since that dependency was added, which was not true of a default build.
- An unknown extension in a TLS 1.3 certificate entry is ignored, where
  upstream rejects the message; Go's crypto/tls ignores it too. That has been
  so on this branch since 94f088e; the README now says it, and the BoGo test
  SendUnknownExtensionOnCertificate-TLS13, which expects the rejection, is
  disabled with that reason.
Upstream's workflows named the package in twelve places (-p rustls,
--package rustls, admin/all-features-except ... rustls); they name
shaped-rustls now, and the MSRV job uses Rust 1.85. CIFuzz runs for the
upstream repository only: OSS-Fuzz does not know this one. fuzz/Cargo.lock
follows the rename, which --locked requires.
rustls-webpki 0.103.15 -> 0.103.17 (RUSTSEC-2026-0382), webpki-roots 1.0.9 ->
1.0.12 (RUSTSEC-2026-0381), tokio 1.53.1 -> 1.54.1 (RUSTSEC-2026-0386) and
hickory-net, hickory-proto and hickory-resolver 0.26.1 -> 0.26.3. The lockfile
serves this repository's own tests and examples; a dependent resolves its own.
crypto-bigint 0.5.5 (RUSTSEC-2026-0387), a dependency of the provider example,
has no compatible fixed release and stays.
The first run with rust-version 1.85 left three jobs red:

- MSRV: its second step still installed 1.75 for the all-features check;
  it installs 1.85 now.
- Clippy: it reads the minimum version from the manifest, and at 1.85 it asks
  to rewrite upstream's code with newer APIs (io::Error::other,
  core::error::Error, repeat_n, div_ceil). rustls/.clippy.toml pins Clippy's
  msrv to upstream's 1.71, so upstream's code is linted as upstream lints it.
- audit: RUSTSEC-2026-0387 against crypto-bigint 0.5.5, which the provider
  example and the ECH test dependencies pull in through elliptic-curve 0.13
  and which has no compatible fixed release; it joins deny.toml's ignore list
  with that reason.

The manifest's homepage repeated its repository, which current Cargo warns
about; it is removed.
With the library clean, Clippy reached two things it had not got to before:

- the shaping tests named std::sync::Arc, which rustls/.clippy.toml disallows
  in favour of the crate's own sync::Arc (86 places), and five of them filled
  a default ClientExtensions field by field. They use crate::sync::Arc and a
  struct initializer now;
- rustls-bench with all features takes rustls-graviola, which is built against
  upstream's rustls package: its types are not this crate's and the bench does
  not compile with it. Before the rename the workspace's [patch] entry put the
  local crate under it. admin/clippy lints the bench with every other feature.
cargo-semver-checks takes the latest release on crates.io as its baseline.
shaped-rustls has none yet, so the job could only fail, and it kept every run
of this branch red. It now asks crates.io first: no crate, no check; any
answer other than found or not found fails the job. After the first release
the check runs as upstream's does.
@aimalygin
aimalygin merged commit 474a31b into xray/rustls-0.23.40 Nov 20, 2026
32 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.