Skip to content

feat(system-tests): make the local backend's ic-gateway reachable by name - #11270

Merged
basvandijk merged 7 commits into
masterfrom
bas/local-backend-gateway-cert
Aug 26, 2026
Merged

basvandijk merged 7 commits into
masterfrom
bas/local-backend-gateway-cert

Conversation

@basvandijk

@basvandijk basvandijk commented Aug 22, 2026 •

Copy link
Copy Markdown
Collaborator

Problem

On the local backend the ic-gateway served a self-signed certificate for <vm name>.local. Neither half is usable from inside the group, so every client papered over both — a reqwest resolve override plus danger_accept_invalid_certs.

That works for driver-side clients and for nothing else. A node has no such knobs, which is why a nested node on this backend registers straight against a replica's :8080 instead of going through the gateway as it does on Farm — and why it needs with_group_wide_firewall_whitelist() to get there.

Both halves turn out to be fixable without touching any node.

The domain

<vm name>.ic.net, registered with the group's dnsmasq through add_dns_record — the same mechanism setup_api_bn_local_playnet already uses for apibn-{idx}.ic.net. The suffix becomes one shared constant.

It could not have stayed under .local: GuestOS and HostOS resolve through systemd-resolved, which routes *.local to mDNS and never to the unicast DNS= servers dnsmasq answers on. No amount of dnsmasq configuration would make such a name resolve in a guest.

Only the apex is registered — a hosts file has no wildcards, and nothing inside a VM resolves a canister subdomain today. A wildcard would mean --address=/<domain>/<addr> on dnsmasq's command line, which SIGHUP does not re-read.

The certificate

Issued by the dev root CA instead of self-signed. That CA is already in every dev IC-OS image's trust store — ic-os/{guestos,hostos}/context/Dockerfile installs canister_http_test_ca.cert and runs update-ca-certificates, in the output_dev stage only — and its private key is checked in beside it. This is how canister_http and ckbtc already serve HTTPS that nodes accept, and the dev-certs/README.md documents exactly this use.

So a node reaches the gateway with no node side configuration: no config-image plumbing, no CONFIG_VERSION bump, no production code change. Production images are unaffected — the CA lives in the output_dev stage.

This deliberately does not extend to the API boundary nodes, whose ephemeral CA stays as it is. nns_delegation_manager builds its root store from the compiled-in webpki_roots and never consults /etc/ssl/certs, which is precisely why extra_api_boundary_node_trust_anchors_pem exists; the client that reaches the gateway is a different one (the orchestrator's ic-agent, which goes through rustls-platform-verifier → the OS store).

Driver side

uses_self_signed_cert gives way to root_certificate(). reqwest adds an extra root to the platform's own rather than replacing them, so clients now verify the chain instead of skipping verification.

resolve_override_for_url stays: the driver sits in the group's network namespace but reads the host's /etc/resolv.conf, whose nameserver is unreachable from there, so driver-side DNS is dead regardless of what dnsmasq knows. Fixing that means giving the driver a mount namespace, which is left for its own change.

Two mechanical additions: x509-parser in rcgen's features, for CertificateParams::from_ca_cert_pem; and rsa, to re-encode the checked-in PKCS#1 CA key as the PKCS#8 that rcgen's ring backend requires.

Verification

dfx_smoke_test_local and nns_dapp_test_local both pass, fetching canister assets over https://<canister id>.ic-gateway.ic.net with the chain verified rather than accepted blindly. dfx_smoke_test and nns_dapp_test still pass on Farm.

#11265 will be restacked on top of this, dropping its plain-HTTP nested path and the group-wide firewall whitelist that goes with it.

🤖 Generated with Claude Code

…name

On the local backend the ic-gateway served a self-signed certificate for
`<vm name>.local`. Both halves are unusable from inside the group, so every
client papered over them with a `reqwest` resolve override plus
`danger_accept_invalid_certs`. That works for driver-side clients and for
nothing else -- a *node* has no such knobs, which is why a nested node
registers straight against a replica's `:8080` on this backend instead of
going through the gateway as it does on Farm.

Both halves turn out to be fixable without touching any node.

The domain moves to `<vm name>.ic.net` and is registered with the group's
`dnsmasq` through `add_dns_record`, the same mechanism
`setup_api_bn_local_playnet` already uses for `apibn-{idx}.ic.net`; the suffix
becomes one shared constant. It could not have stayed under `.local`: GuestOS
and HostOS resolve through systemd-resolved, which routes `*.local` to mDNS and
never to the unicast `DNS=` servers `dnsmasq` answers on, so no amount of
dnsmasq configuration would make such a name resolve in a guest.

The certificate is now issued by the dev root CA instead of being self-signed.
That CA is already in every *dev* IC-OS image's trust store --
`ic-os/{guestos,hostos}/context/Dockerfile` installs
`canister_http_test_ca.cert` and runs `update-ca-certificates` in the
`output_dev` stage -- and its private key is checked in beside it, which is how
`canister_http` and `ckbtc` already serve HTTPS that nodes accept. So a node
can reach the gateway with no node-side configuration at all, and no production
code and no IC-OS config has to change.

This deliberately does not extend to the API boundary nodes, whose ephemeral CA
stays as it is: `nns_delegation_manager` builds its root store from the
compiled-in `webpki_roots` and never consults `/etc/ssl/certs`, which is
precisely why `extra_api_boundary_node_trust_anchors_pem` exists.

Driver-side, `uses_self_signed_cert` gives way to `root_certificate()`, since
`reqwest` adds an extra root to the platform's own rather than replacing them:
clients now verify the chain instead of skipping verification.
`resolve_override_for_url` stays. The driver sits in the group's network
namespace but reads the host's `/etc/resolv.conf`, whose nameserver is
unreachable from there, so driver-side DNS is dead regardless of what `dnsmasq`
knows; fixing that means giving the driver a mount namespace, and is left for
its own change.

Adding `x509-parser` to `rcgen`'s features is what makes
`CertificateParams::from_ca_cert_pem` available, and the new `rsa` dependency
re-encodes the checked-in PKCS#1 CA key as the PKCS#8 that `rcgen`'s `ring`
backend requires.

Verified on the local backend: `dfx_smoke_test_local` and `nns_dapp_test_local`
both pass, fetching canister assets over `https://<canister
id>.ic-gateway.ic.net` with the chain verified rather than accepted blindly.
`dfx_smoke_test` and `nns_dapp_test` still pass on Farm.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Enables locally hosted IC gateways to use in-group DNS and CA-verified TLS.

Changes:

  • Registers local gateway domains through dnsmasq.
  • Issues gateway certificates from the dev root CA.
  • Updates clients and Rust/Bazel dependencies for certificate verification.

Reviewed changes

Copilot reviewed 10 out of 13 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
rs/tests/sdk/src/asset.rs Verifies gateway TLS certificates.
rs/tests/nns/nns_dapp_test.rs Verifies TLS for dapp requests.
rs/tests/driver/src/driver/local_backend.rs Defines the shared in-group domain.
rs/tests/driver/src/driver/ic.rs Reuses the shared domain suffix.
rs/tests/driver/src/driver/ic_gateway_vm.rs Adds CA signing, DNS registration, and trust handling.
rs/tests/driver/Cargo.toml Adds RSA support.
rs/tests/driver/BUILD.bazel Adds the Bazel RSA dependency.
rs/tests/common.bzl Provides CA certificate and key runfiles.
Cargo.toml Enables rcgen X.509 parsing.
Cargo.lock Updates Cargo dependency resolution.
Cargo.Bazel.toml.lock Updates Bazel’s Cargo lock state.
Cargo.Bazel.json.lock Updates generated Bazel crate metadata.
bazel/rust.MODULE.bazel Enables rcgen X.509 parsing for Bazel.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

…cate

A wildcard SAN matches a single label, so `*.<domain>` does not cover
`<canister id>.raw.<domain>` -- the canonical raw hosts, which the Farm path
gives their own `*.raw` CNAME. Add the matching SAN so the local certificate
covers what Farm's does.

Nothing is broken today: the only three places that build a raw host are two
Prometheus scraping-target files, consumed inside a universal VM with its own
trust store, and one nns-dapp metadata string for a canister the driver does not
deploy. But the gap is a trap for the next caller, and more so once the
driver-side resolve overrides go away.

Note the certificate is now ahead of DNS here: the group's `dnsmasq` is served a
hosts file, which has no wildcards, so only the apex is registered and a
subdomain still has to be resolved by the client.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
basvandijk and others added 2 commits August 23, 2026 01:03
The dev root CA was added to `IC_GATEWAY_RUNTIME_DEPS`, which feeds *every*
variant of a gateway-using target -- Farm and `_colocate` included -- even though
only the local backend ever reads it. For a colocated target that is worse than
dead weight: `colocate_test.rs` tars the runtime-deps directory and copies it to
the driver's universal VM, so around thirty Farm targets were shipping a CA
signing key to a VM with no use for it. The key is public, so nothing is
compromised, but there is no reason to send it.

Move both files to `_local_only_deps` in `system_tests.bzl`, which is plumbed
into the `_local` variant alone, and rename the variables to the `ENV_DEPS__`
prefix that channel uses. Verified through the runfiles manifests:
`dfx_smoke_test_local` has both entries, `dfx_smoke_test` has neither, and both
still pass -- the Farm path never touches them.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Five claims in the comments added with this feature were wrong. None changes
behaviour; all of them would mislead the next reader.

- The PKCS#1 re-encode was justified by `rcgen`'s "default `ring` backend".
  `aws_lc_rs` is in fact enabled workspace-wide (`rustls-acme` -> `ic-bn-lib` ->
  `ic-boundary` -> `pocket-ic-server`) and `rcgen` prefers it when both features
  are on, so the backend in use loads PKCS#1 directly and the conversion is not
  strictly needed. Keep it -- correctness should not hinge on a transitive
  feature of an unrelated crate, where a dependency edit surfaces as a runtime
  failure in every local gateway test -- but say that instead.
- `signed_by` was said to write the CA's subject key identifier into the leaf's
  authority key identifier. `rcgen` emits an AKI only when
  `use_authority_key_identifier_extension` is set, which `CertificateParams::new`
  leaves false; the leaf's only extension is its SAN. The issuer name and the
  signature are what make the chain verify.
- Serving the root in `chain_pem` was justified as sparing the client an AIA
  fetch. There is no intermediate to fetch, and RFC 8446 4.4.2 lets the root be
  omitted, so a trusting client gains nothing. It is kept because it makes the
  served chain self-describing while debugging a handshake.
- `root_certificate` claimed no CA vouches for an API boundary node's
  certificate. Under `with_api_boundary_nodes_playnet` one does. The reason those
  clients still need `danger_accept_invalid_certs` is that
  `IcNodeSnapshot::get_public_url` gives them an IP-literal URL, which no name in
  the certificate can match.
- Apex-only DNS registration was justified with "nothing inside a VM resolves a
  canister subdomain today". `prometheus_vm` writes `<canister id>.raw.<domain>`
  scrape targets that the Prometheus VM resolves through this very `dnsmasq`.
  They have never resolved on this backend -- the domain was an equally
  unresolvable `.local` name before -- so nothing regressed, but the comment
  asserted the opposite of the code it was justifying.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This pull request changes code owned by the Governance team. Therefore, make sure that
you have considered the following (for Governance-owned code):

  1. Update unreleased_changelog.md (if there are behavior changes, even if they are
    non-breaking).

  2. Are there BREAKING changes?

  3. Is a data migration needed?

  4. Security review?

How to Satisfy This Automatic Review

  1. Go to the bottom of the pull request page.

  2. Look for where it says this bot is requesting changes.

  3. Click the three dots to the right.

  4. Select "Dismiss review".

  5. In the text entry box, respond to each of the numbered items in the previous
    section, declare one of the following:

  • Done.

  • $REASON_WHY_NO_NEED. E.g. for unreleased_changelog.md, "No
    canister behavior changes.", or for item 2, "Existing APIs
    behave as before.".

Brief Guide to "Externally Visible" Changes

"Externally visible behavior change" is very often due to some NEW canister API.

Changes to EXISTING APIs are more likely to be "breaking".

If these changes are breaking, make sure that clients know how to migrate, how to
maintain their continuity of operations.

If your changes are behind a feature flag, then, do NOT add entrie(s) to
unreleased_changelog.md in this PR! But rather, add entrie(s) later, in the PR
that enables these changes in production.

Reference(s)

For a more comprehensive checklist, see here.

GOVERNANCE_CHECKLIST_REMINDER_DEDUP

@basvandijk basvandijk added the CI_ALL_BAZEL_TARGETS Runs all bazel targets label Aug 25, 2026
`DEV_ROOT_CA_CERT_ENV` and `DEV_ROOT_CA_KEY_ENV` each had a single use,
so naming them only moved the string away from the call that reads it.
Pass the variable names directly to `get_dependency_path_from_env` and
keep the note about where they come from — and about the Farm backend
never reading them — on `DevRootCa`, which is what the two functions
build.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 10 out of 13 changed files in this pull request and generated no new comments.

@basvandijk
basvandijk added this pull request to the merge queue Aug 26, 2026
Merged via the queue into master with commit 018315b Aug 26, 2026
69 of 70 checks passed
@basvandijk
basvandijk deleted the bas/local-backend-gateway-cert branch August 26, 2026 11:45
pull Bot pushed a commit to bit-cook/ic that referenced this pull request Aug 27, 2026
> Stacked on dfinity#11270, which gives the local backend's ic-gateway a
resolvable domain and a certificate that nodes trust. Review that one
first.

## Problem

Nested system-tests (`rs/tests/nested`) drive the whole node deployment
chain: SetupOS installs HostOS onto a blank disk, HostOS boots a nested
GuestOS VM, and that GuestOS registers with the NNS. All five
non-bare-metal targets were pinned to Farm because
`setup_and_start_nested_vms` was not supported on the local backend.

## What was missing

Three things in the driver:

- the install target was built as a `DiskImage::Url` whose `_URL`
variable `run_systest.sh` never sets under the local backend;
- `setup_and_start_nested_vms` needed its `Local` arm;
- `NESTED_CONFIG_IMAGE_PATH` claimed `.zst` for a file nothing
compresses, which the local backend would have run `unzstd` over.

The fourth — the nested node's NNS URL — is what dfinity#11270 is for. A node
that is not in the registry yet cannot pass the replicas' firewall, so
it registers through the ic-gateway; that needed the gateway to be
reachable by name and trusted, which it now is on both backends.
`nested_nns_url` is consequently backend-agnostic.

Also: `pad_to_request_alignment` now refuses a GPT image rather than
silently displacing its backup header, and the nested VM drops from 32
GiB to 16 GiB — the floor, since the driver takes 8 GiB off and HostOS
then takes 4 more, leaving the GuestOS the same 4 GiB every other node
VM gets. That reduction applies on Farm too; all 20 Farm nested targets
pass with it.

## The blocker: SetupOS halts because chrony can never synchronise

`check-ntp.sh` is the one SetupOS check *not* gated on
`ic.setupos.run_checks`, so `setupos-disable-checks` does not skip it.
It waits 60s for `NTPSynchronized` and then halts the installation
*forever* — `log_and_halt_installation_on_error` ends in `sleep
infinity`.

Serving NTP to the group ourselves does not fix it, and the first two
commits here do exactly that before it is reverted. chrony's
`authselectmode` defaults to `mix`, and `sources.c` then marks the
*authenticated* sources `require`d as soon as both authenticated and
unauthenticated sources are configured — precisely what `chrony.conf`
does in pairing fourteen `nts` servers with two plain pools. Sources
configured from names that never resolve still count. So the clock can
only ever be synchronised from one of those fourteen NTS servers; the
driver's SNTP server was polled every 64s for a whole run and never
selected, with chronyd saying so in the node journals:

```
Can't synchronise: no required source in selectable sources
```

Reproduced against chronyd 4.8 directly: given that config shape it
polls a reachable plain server for 100s without selecting it, and
selects it in 4s once `authselectmode ignore` is added. Satisfying the
check for real would mean serving NTS under one of those fourteen
hostnames with a certificate the guest trusts, which no test harness can
arrange.

So the check is gated instead, like the four that also need
connectivity, and the reasoning is recorded on `check_ntp`. Nothing is
lost: every test VM takes its clock from the hypervisor via `-rtc
base=utc`.

## Scope

`registration` and both `*_upgrade_smoke_test` targets are un-pinned,
along with the `_head_nns` variants `system_test_nns` generates from
them — `backend` is per target definition. All six were run locally
before dropping the pins.

The two `*_from_latest_release_to_current` targets stay pinned: they
install from a prebuilt *mainnet* SetupOS image, of which
`setupos-disable-checks` can only rewrite the grub boot args, so their
`check-ntp.sh` predates this gate.

One thing for reviewers to weigh: this takes the non-manual nested
`_local` targets from two to six, and `system_tests.bzl:342` reserves
CPU only — `ceil(cpus / cpus_oversubscription_factor)` = 9 of the 27
these declare — with no accounting for memory or disk. Three can
therefore run concurrently on a 32-core runner, for ~84 GiB of nominal
VM memory and ~60 GiB of qcow2 overlays. `cpus_oversubscription_factor =
1` would serialise them if that turns out to matter; no target in the
repo sets it today, so this is left at the default.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

---------

Co-authored-by: Claude Opus 5 (1M context) <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants