XNetworking: read the certificate chain through the SDK's layouts #37
No reviewers
Labels
No labels
accessibility
bug
documentation
duplicate
enhancement
goal:world-load
good first issue
help wanted
invalid
keep-open
off-goal
question
stale
test-only
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/xcl-dev--xcl!37
Loading…
Reference in a new issue
No description provided.
Delete branch "gh-pr/37/head"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
@grooving6 on GitHub · 2026-11-22 17:30 UTC · original
fix/xnetworking-cert-chain-offsets→main· +107 −21 · 2 files · 1 commits · closed without mergingProblem
extract_chain_certs(hle/xgameruntime/networking.rs) walks the chain with hand-written x64 offsets that don't matchwincrypt.h:CERT_CHAIN_CONTEXT.cChainCERT_CHAIN_CONTEXT.rgpChainCERT_SIMPLE_CHAIN.cElementCERT_SIMPLE_CHAIN.rgpElementAt +24 sits
cLowerQualityChainContextplus padding, so the walk usually finds no certificates andXNetworkingVerifyServerCertificatefails every thumbprint pin withCERT_E_UNTRUSTEDROOT. If those bytes are ever non-zero, it follows a junk pointer instead.docs/xnetworking-rust-review.mdalready flagged that these offsets "do not look consistent with the documented field order".Fix
The chain is now read through
windows-sys'sCERT_CHAIN_CONTEXT,CERT_SIMPLE_CHAINandCERT_CHAIN_ELEMENT, which needs one newwindows-sysfeature,Win32_Security_Cryptography. The function also gets a# Safetysection and// SAFETY:comments. Nothing else changes: TLS policy, pin matching and result handling stay as they were.Tests
cert_context_matches_sdk_layout: the module's ownCertContextchecked against the SDK'sCERT_CONTEXT(size and every field offset).chain_certs_follow_sdk_layout: a two-certificate chain built from the SDK structs must come back leaf first. Null and zero-count chains come back empty.chain_certs_from_crypt32: a real chain fromCertGetCertificateChainfor a certificate in the machine's root store must have that certificate as its leaf, compared by SHA-1. If the root store is empty, the test skips instead of failing.I checked that the tests catch the bug: with the old offsets put back temporarily,
chain_certs_follow_sdk_layoutandchain_certs_from_crypt32both fail, because both get an empty list. That includes the real crypt32 chain.What ran
Windows 11, Rust 1.100
x86_64-pc-windows-msvc, MSVC 14.44, Windows SDK 10.0.26100 (DXC from it), AMD Radeon RX 7900 XTX (RDNA3):cargo build --workspace+cargo test --workspace -- --test-threads=4: 344 passed, 0 failed, 34 ignored (the opt-in#[ignore]probes and surveys).System32\xgameruntime.dll). Both runs pass.gpu::tests: 157 passed). The README lists GPUs other than RDNA4 as untested, so this is also a first data point for RDNA3.XCL_SAMPLE_*game data was set, so those tests ran without doing anything.cargo clippy -p xcl --all-targets: no warnings on the changed lines. The rest of the file and the crate already had warnings, and I left those alone.🤖 Generated with Claude Code
Pull request closed