XNetworking: read CERT_CHAIN_CONTEXT at its real offsets #47

Manually merged
github merged 1 commit from gh-pr/47/head into gh-pr/47/base 2026-11-26 04:06:17 +00:00
Owner

@⁠gefydev on GitHub · 2026-11-22 21:32 UTC · original
gefydev:xnetworking-chain-offsets → main · +73 −27 · 1 files · 1 commits · merged 2026-11-22 21:41 UTC

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.
**@⁠gefydev** on GitHub · 2026-11-22 21:32 UTC · [original](https://github.com/xcl-dev/xcl/pull/47) `gefydev:xnetworking-chain-offsets` → `main` · +73 −27 · 1 files · 1 commits · merged 2026-11-22 21:41 UTC `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.
extract_chain_certs read cChain / rgpChain at +16 / +24 and cElement /
rgpElement at +20 / +24. In wincrypt.h both structs have cbSize and an
8-byte CERT_TRUST_STATUS first, so the counts sit at +12 and the arrays
at +16. At +24 of the chain context is cLowerQualityChainContext, so the
walk found no chain and XNetworkingVerifyServerCertificate failed every
thumbprint pin with CERT_E_UNTRUSTEDROOT.

The chain is now read through small repr(C) structs. The test builds a
chain byte by byte at the documented offsets; the old code returns no
certificates for it.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 04:06:13 +00:00
github manually merged commit 28ee5d74c9 into gh-pr/47/base 2026-11-26 04:06:17 +00:00
Author
Owner

@⁠ivall on GitHub · 2026-11-22 21:42 UTC · original

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.

**@⁠ivall** on GitHub · 2026-11-22 21:42 UTC · [original](https://github.com/xcl-dev/xcl/pull/47#issuecomment-7086247483) 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.
This discussion has been locked. Commenting is limited to contributors.
No description provided.