XNetworking: read CERT_CHAIN_CONTEXT at its real offsets #46

Merged
gefydev merged 1 commit from upstream-pr/47 into main 2026-11-22 21:41:50 +00:00
gefydev commented 2026-11-22 21:32:36 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by gefydev on 2026-11-22T21:32:36Z.


extract_chain_certs read cChain / rgpChain at +16 / +24 and cElement / rgpElement at +20 / +24. Both structs start with cbSize and an 8-byte CERT_TRUST_STATUS, so in wincrypt.h the counts are at +12 and the arrays at +16. The walk found no chain, and XNetworkingVerifyServerCertificate failed every thumbprint pin with CERT_E_UNTRUSTEDROOT. This only affects titles that pass pins; without pins the chain's certificates are not compared.

The chain is now read through small repr(C) structs, like the other CryptoAPI structs in the file, so no new windows-sys feature is needed. #37 fixed the same thing and was closed by its author. This is a smaller version of that fix.

Validation

  • New test chain_certs_read_at_the_sdk_offsets builds a chain byte by byte at the documented offsets. It fails on main (no certificates come back) and passes with the fix.
  • cargo test -p xcl --lib: 330 passed, 0 failed, on Windows GNU under Wine. I did not run the e2e or GPU tests.
<!-- greyfinch-sync:ivall/xcl:issue:6548061602 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/47). Originally posted by [gefydev](https://github.com/gefydev) on 2026-11-22T21:32:36Z. --- `extract_chain_certs` read `cChain` / `rgpChain` at +16 / +24 and `cElement` / `rgpElement` at +20 / +24. Both structs start with `cbSize` and an 8-byte `CERT_TRUST_STATUS`, so in `wincrypt.h` the counts are at +12 and the arrays at +16. The walk found no chain, and `XNetworkingVerifyServerCertificate` failed every thumbprint pin with `CERT_E_UNTRUSTEDROOT`. This only affects titles that pass pins; without pins the chain's certificates are not compared. The chain is now read through small `repr(C)` structs, like the other CryptoAPI structs in the file, so no new `windows-sys` feature is needed. #37 fixed the same thing and was closed by its author. This is a smaller version of that fix. ## Validation - New test `chain_certs_read_at_the_sdk_offsets` builds a chain byte by byte at the documented offsets. It fails on `main` (no certificates come back) and passes with the fix. - `cargo test -p xcl --lib`: 330 passed, 0 failed, on Windows GNU under Wine. I did not run the e2e or GPU tests.
upstream-sync closed this pull request 2026-11-24 06:56:54 +00:00
ivall commented 2026-11-24 07:00:20 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by ivall on 2026-11-22T21:42:01Z.


Thanks, merged! The offsets match wincrypt.h on x64: cChain / cElement @ +12 after cbSize and the 8-byte CERT_TRUST_STATUS, the arrays @ +16, pCertContext @ +8. I checked it with the MSVC toolchain on Windows: all tests pass, 337 lib tests with your new one, the e2e test title, and the GPU tests.

<!-- greyfinch-sync:ivall/xcl:comment:7086247483 --> Imported from [ivall/xcl](https://github.com/ivall/xcl/pull/47#issuecomment-7086247483). Originally posted by [ivall](https://github.com/ivall) on 2026-11-22T21:42:01Z. --- Thanks, merged! The offsets match `wincrypt.h` on x64: `cChain` / `cElement` @ +12 after `cbSize` and the 8-byte `CERT_TRUST_STATUS`, the arrays @ +16, `pCertContext` @ +8. I checked it with the MSVC toolchain on Windows: all tests pass, 337 lib tests with your new one, the e2e test title, and the GPU tests.
Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
xcl-dev/xcl!46
No description provided.