Skip to content

Add API to install trusted CA certs in the open source build - #427

Open
ResakaGit wants to merge 1 commit into
ValveSoftware:masterfrom
ResakaGit:feat-237-manual-cert-auth
Open

Add API to install trusted CA certs in the open source build#427
ResakaGit wants to merge 1 commit into
ValveSoftware:masterfrom
ResakaGit:feat-237-manual-cert-auth

Conversation

@ResakaGit

Copy link
Copy Markdown

In the open source build there is no way to install a root of trust: CertStore_AddCertFromBase64 has no callers, the cert store only ever contains the hardcoded Valve root CA key, and with that key defined, dynamically added self-signed certs are always rejected. So certificate verification can never succeed for certs issued by anybody else, and manually-issued certs (#237) are unusable end to end, no matter what the certtool produces.

This adds two global functions to the open source API surface (no changes to the frozen interfaces, the config enum, or the wire format):

  • GameNetworkingSockets_AddTrustedCert installs a CA cert (PEM-like blob or raw base64 body) in the trust store. Certs installed this way are marked as explicitly trusted by the app and may act as self-signed trusted roots, coexisting with the hardcoded root CA key, which remains trusted. Certs that arrive any other way are rejected exactly as before, so the hardcoded-root invariant is preserved for anything the app didn't explicitly vouch for. The same call installs intermediate certs, since the wire format only carries the signing key ID, not the chain.
  • GameNetworkingSockets_SetAppID sets the app ID used by certificate validation. Both ends check certs against their own app ID, but in the open source build it was stuck at 0, so those checks could never pass.

It also resurrects test_pki, which was added in 0da061c but never hooked up to the build. The checked-in certs were signed by a root key that does not match the current hardcoded key, so the old corpus could not be revived; the test now generates its PKI at runtime (self-signed root, intermediates, chain intersection, revocation, and the new app-trust provenance behavior, both positive and negative), and is wired into CI on all platforms. Verified locally on Windows (MSVC 2022): test_pki and test_connection suite-quick both pass.

This is the first part of #237, following the plan outlined there in 2022: certtool support for specifying the cert identity and for emitting the private key alongside the cert (which SetCertificate already accepts, closing #384) would come as a follow-up PR. I posted a few design questions on the issue.

🤖 Generated with Claude Code

In the open source build there was no way to install a root of trust:
CertStore_AddCertFromBase64 had no callers, the cert store only ever
contained the hardcoded Valve root CA key, and with that key defined,
dynamically added self-signed certs were always rejected.  So the
verification path could never succeed for certs issued by anybody
else, and manually-issued certs (issue ValveSoftware#237) were unusable.

Add GameNetworkingSockets_AddTrustedCert, which accepts a PEM-like
blob or the raw base64 body of one, and installs a cert in the trust
store.  Certs installed this way are marked as explicitly trusted by
the app and may act as self-signed trusted roots, coexisting with the
hardcoded root CA key, which remains trusted.  Certs that arrive any
other way are rejected exactly as before, so the hardcoded-root
invariant is unchanged for certs the app didn't vouch for.  The same
function installs intermediate certs.  (The wire format doesn't carry
the chain, so the verifying side needs the whole chain in its store.)

Also add GameNetworkingSockets_SetAppID.  Certificates are authorized
for particular app IDs and both ends check certs against their own app
ID, but in the open source build there was no way to set it, so it was
always 0 and those checks could never pass.

Resurrect test_pki, which was added in 0da061c but never hooked up to
the build.  Its checked-in certs were signed by a root key that does
not match the current hardcoded key, so the corpus could not be
revived; the test now generates its PKI at runtime instead, which also
removes the frozen timestamps.  Hook it up to CI on all platforms.

This is the first part of issue ValveSoftware#237.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
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.

1 participant