Introducing a new way to review your PRs.

Read the announcement

arcboxlabs / arcbox

Run AI agents on real and isolated machines — own kernel, filesystem, and network — with <100ms boot. Local first, OCI compatible, pure Rust.

View on GitHub

32 documents · Updated Nov 6, 2026

docs / local-ca-and-trust-lifecycle

Local CA and trust lifecycle

ArcBox uses one per-profile local certificate authority (CA) to secure managed HTTPS for local service names. The private key stays in the host user's macOS Keychain while the public certificate moves through separate host, helper, and guest trust paths. See Local service access and trust for the wider access model and Machine web service access for machine-specific HTTPS behavior.

Authority model

The local CA signs server certificates for ArcBox-managed names below .local. Its certificate policy excludes IP addresses and subordinate CAs, so trusting the root gives local HTTPS trust without granting public-DNS signing power.

Key and certificate ownership

The daemon creates or reopens one CA identity for each profile. The private key remains non-exportable in the user's file Keychain. ArcBox shares only the public certificate as tls/ca.pem; a guest can request a certificate while connected but cannot obtain the CA key from the shared data.

The profile records the selected public identity in tls/identity.json. This record also keeps enough information to recover an interrupted rotation and revoke an exact retired root. The old file-backed tls/ca-key.pem is removed before the data directory is available to a guest.

References: common/…/keychain.rs• L21-40 common/…/journal.rs• L27-60 common/…/migration.rs• L24-31 common/…/paths.rs• L590-600

Certificate signing scope

The CA policy limits the root to DNS names strictly below .local. This scope is only a cryptographic limit. The host still checks current DNS ownership and the captured service route before it signs a certificate request.

The guest keeps leaf private keys in memory. The host checks the requested name and the current service owner, signs the request with the active Keychain identity, and the guest verifies the returned leaf against that name and root before serving HTTPS.

References: common/…/authority.rs• L10-31 common/…/request.rs• L1-120 app/…/tls_signer.rs• L109-137

Host trust layers

ArcBox separates certificate storage from trust authorization. This prevents a privileged helper from silently granting browser or system trust and lets HTTPS remain optional for normal VM and container startup.

Helper storage boundary

The privileged helper accepts validated public certificate bytes. It stores the exact certificate in the macOS System Keychain and reports whether that copy has the required TLS-server-only Admin trust. It never receives a private key or a caller-selected path.

Removing a certificate requires its Admin trust to be revoked first. Matching uses the full certificate identity, so removal does not delete another profile's root. The helper's storage operation is therefore a public-certificate boundary, not the user authorization boundary.

References: app/…/handler.rs• L160-180 app/…/ca.rs• L17-54

Login-session authorization

The host user's login-session process changes macOS trust through native Security.framework calls. It grants only TLS server trust in the Admin domain and treats any User-domain trust as a legacy override that must be removed during explicit trust setup.

Status inspection does not create keys or change trust. A current root is ready only when it is valid, published, present in the helper's System Keychain copy, trusted with the precise Admin policy, and free of the legacy User override. Existing correct trust needs no new authorization.

References: common/…/trust.rs• L33-85 app/…/local_https.rs• L15-23 app/…/local_https.rs• L79-141

Trust and runtime independence

CA preparation and trust status run independently of Docker and VM readiness. A user can cancel or postpone native trust authorization while containers and other non-managed HTTPS paths continue to work. The daemon reports the CA problem as HTTPS state instead of treating it as a general startup failure.

References: app/…/tls.rs• L19-50 docs/…/0006-authorize-local-ca-in-user-session.md• L12-22

Authority creation and publication

Preparation restores one usable public identity without changing native trust. The daemon takes the profile operation lock, opens or creates the Keychain identity, removes any exposed legacy key, and publishes the matching public certificate.

The publication step is safe to retry. If the shared certificate is missing, the daemon can recreate it from the recorded Keychain identity. If the file contains a different or ambiguous certificate, ArcBox preserves it for explicit recovery instead of overwriting evidence that may still need trust revocation.

The following flow shows how the private identity becomes a public certificate and then becomes available to the helper and signing service.

flowchart LR
    A[Profile preparation] --> B[Keychain CA identity]
    B --> C[Public ca.pem]
    C --> D[Helper System Keychain copy]
    B --> E[Host signing service]
    E --> F[Validated local leaf certificates]

Publication repair

Repair restores only the current profile's public certificate. It does not create a new key and does not grant trust. An expired root cannot be repaired for new HTTPS use; it must be renewed through rotation.

References: app/…/tls.rs• L53-108 common/…/migration.rs• L41-73

Rotation lifecycle

Rotation replaces the CA identity while preserving exact knowledge of both roots until trust cleanup finishes. It uses a prepare step and a commit step so a user authorization prompt can occur between identity creation and publication.

The rotation moves through these stages:

  1. The daemon records a pending replacement and creates its new Keychain identity.
  2. The login-session action trusts the replacement with TLS-server-only Admin trust.
  3. The same action removes User and Admin trust for the exact previous root.
  4. The daemon verifies both fingerprints, publishes the replacement, switches signing to it, and deletes the retired identity.
  5. The journal returns to a stable record that names only the replacement.
sequenceDiagram
    participant D as Daemon
    participant K as User Keychain
    participant U as Login session
    participant H as Helper
    participant G as Guest

    D->>K: Create replacement identity
    D->>D: Record pending rotation
    U->>K: Authorize replacement trust
    U->>K: Revoke previous User/Admin trust
    U->>H: Store replacement public certificate
    D->>D: Publish replacement and switch signer
    D->>G: Reconcile replacement root
    D->>K: Remove retired identity

The previous public certificate remains published when its trust is still present. This prevents the daemon from publishing a root that no longer matches the trusted state. An interrupted operation keeps both identities in the journal so a later retry can finish the exact pending transition.

References: common/…/rotation.rs• L35-157 common/…/journal.rs• L41-60 app/…/rotation.rs• L9-87

Guest trust boundary

Guest client trust is separate from macOS native trust. After the daemon has a published active root, it sends the public certificate to each ready guest through a host-only trust connection. The guest acknowledges only after its own trust store has been durably updated.

System VM trust

The System VM replaces only the ArcBox-owned section of its regular PEM bundle. Other roots remain unchanged. A root removal removes that owned section, but does not depend on the writable guest share and does not remove unrelated trust.

References: guest/…/mod.rs• L109-123 guest/…/guest_trust.rs• L35-45 common/…/bundle.rs• L15-56

Machine trust

Supported Debian, Ubuntu, and Alpine machines receive the root through the owned source anchor at /usr/local/share/ca-certificates/arcbox-local-ca.crt. The machine runs its normal update-ca-certificates process, verifies the rebuilt bundle, and only then acknowledges the change. Missing stores, unsupported distributions, updater failure, or a false updater result leave reconciliation pending for retry.

References: guest/…/mod.rs• L95-105 guest/…/machine.rs• L20-59

Delivery authorization and ordering

Only the host may request guest trust changes. The daemon pins delivery to the physical guest incarnation and root fingerprint. The guest rejects stale trust connections, serializes writes, and completes an in-progress write before allowing cancellation or a newer root to take over.

The trust path is independent of the HTTPS proxy's route authority. Installing a root in a guest client bundle does not authorize a hostname, create a DNS claim, or permit the guest proxy to serve a route.

References: app/…/guest_trust.rs• L22-31 app/…/guest_trust.rs• L87-143 guest/…/guest_trust.rs• L84-143 guest/…/rpc.rs• L112-123

Trust state relationships

The parts of the lifecycle answer different questions. A green result in one layer does not prove that the other layers are ready.

LayerResourceWhat success means
Key ownershipUser KeychainThe host can retain and use the private signing identity.
Public storagetls/ca.pem and helper System KeychainConsumers can obtain the expected public root.
macOS trustLogin-session Admin trustmacOS can validate ArcBox-managed server certificates for the TLS server policy.
Guest client trustSystem VM or machine trust storeGuest client programs can validate the active ArcBox root.
Service authorizationDNS owner, route, and CSR checksA leaf may be issued and served for one current managed name.

Change checklist

When these files or sections are changed, remember to consider these:

  • Keep the Keychain identity record, public ca.pem, helper certificate copy, and active signer aligned by exact certificate fingerprint.
  • Keep rotation recovery able to identify both the previous and candidate roots until trust revocation and old-identity deletion finish.
  • Preserve the split between helper certificate storage and login-session native trust authorization.
  • Keep System VM bundle updates and machine source-anchor updates limited to the ArcBox-owned certificate section.
  • Keep guest trust acknowledgements tied to the physical guest identity and the root fingerprint.
  • Keep CSR name authorization tied to the current DNS owner and installed route. CA name constraints alone are not ownership proof.

Important failure modes

TriggerConsequenceGuard
Legacy private key remains in the shared profile dataA guest can copy a former signing keyRemove tls/ca-key.pem before guest sharing and block host admission if removal fails.
Previous root remains trusted during replacementNew ca.pem would no longer match the trusted rootPreserve the previous publication until exact User and Admin trust revocation succeeds.
User trust override remainsBroad or conflicting User settings prevent the required Admin-only stateRemove legacy User trust during explicit login-session authorization.
Guest updater fails after the source anchor changesThe guest bundle may not contain the requested rootVerify the rebuilt bundle before acknowledging and replay the reconciliation.
A stale guest connection writes after a newer oneAn older root can replace the current guest trustOrder connections and reject older requests before writing.
Root trust is present but DNS ownership or route changesA certificate could be issued for the wrong serviceRecheck the captured owner and route around signing and HTTPS forwarding.

Key files

FileWhy to read it
common/…/lib.rsDefines the CA trust model and public lifecycle surface.
common/…/keychain.rsShows how the per-profile private identity is retained without export.
common/…/rotation.rsShows the prepare, authorize, publish, and cleanup contract.
common/…/migration.rsShows public publication, repair, and legacy-key removal.
app/…/ca.rsShows the helper's public-certificate storage boundary.
app/…/tls.rsShows background preparation and HTTPS status independence from VM startup.
app/…/guest_trust.rsShows root delivery to ready guest incarnations.
guest/…/guest_trust.rsShows serialized guest trust writes and acknowledgements.
guest/…/machine.rsShows the supported machine trust boundary and updater contract.
app/…/local_https.rsDefines the read-only relationship between validity, publication, and native trust.