WendyOS Docs
Detailed reference

Certificates and device trust

Wendy uses certificates to check that you are connecting to the intended device and that your account belongs to its organization.

Certificates and device trust

Wendy uses certificates to check that you are connecting to the intended device and that your account belongs to its organization. The CLI manages certificates when you sign in and enroll; normal use does not require editing certificate files.

Common tasks

The sections below are an advanced reference for administrators investigating trust or self-hosted deployments. Mutual TLS (mTLS) means both sides authenticate with certificates. Wendy Cloud or your self-hosted certificate service issues them.

Certificate roles

CertificateIssued toUsed for
Device certwendy-agent during provisioningmTLS server identity; stored in /etc/wendy-agent/provisioning.json
CLI certDeveloper machine via wendy auth loginmTLS client auth when connecting to provisioned devices

The device's mTLS CA pool is built from the chainPem field in provisioning.json. CLI clients must present a certificate whose chain terminates at that same CA. If chainPem is absent or empty, the agent refuses to build a TLS configuration and returns an error indicating that the device may need to be re-provisioned.

Credential persistence

On WendyOS, the agent keeps enrollment state in /etc/wendy-agent/:

FileContentsPermissions
device-key.pemDevice private key0600
provisioning.jsonEnrollment details, device certificate (certPem) and CA chain (chainPem); new writes exclude the private key0600

Unchanged saves and agent restarts preserve these files when their contents and permissions are already correct. Required updates and permission repairs still write the affected file; the Go agent uses atomic replacement and filesystem syncing. When migrating an older JSON file containing keyPem, the agent saves the separate key before removing the embedded copy.

The agent no longer emits device.pem, ca.pem or .provisioned. Unprovisioning still removes copies left by older agents. Agent services, including the embedded container registry, receive credentials in memory; these persistence files are internal agent state, not an app credential API.

The macOS agent (Swift) follows the same layout for software-backed keys. With a Secure Enclave key, there is no device-key.pem; the wrapped key is held in the Keychain.

Certificate identity and URI SAN

Every CSR generated by the CLI and agent now carries the authoritative Wendy identity as a URI Subject Alternative Name in addition to the legacy Subject CommonName:

EntityURI SAN format
Operator (certificate service identity endpoint)spiffe://wendy.sh/tenant/‹uuid›/operator/‹sub›
User (CLI, cloud-relayed)spiffe://wendy.sh/tenant/‹uuid›/service/user-‹userID›
Device / agent (cloud-relayed)spiffe://wendy.sh/tenant/‹uuid›/service/asset-‹assetID›
Device (ACME / EST, direct)spiffe://wendy.sh/tenant/‹uuid›/device/‹deviceID›
User (CLI) — legacy chainurn:wendy:org:‹orgID›:user:‹userID›
Device / agent — legacy chainurn:wendy:org:‹orgID›:asset:‹assetID›

The tenant SPIFFE principal is the identity. It is what IdentityFromCert (Go) and OrgIdentity.identity(fromLeaf:) (Swift) resolve first, because it is the only identity certificate service carries across a renewal: the renew path replaces a CSR's URI SAN list wholesale with the principal read off the presented certificate, so a renewed leaf comes back with its urn:wendy:org:… SAN gone.

The urn:wendy:org:… SAN is read second and only as a legacy old-chain identity. On a transitional leaf that carries both, the principal decides who the caller is and the URN contributes only its organisation, so a peer that can still compare nothing but organisations keeps working. The CommonName (sh/wendy/‹org›/‹asset› or wendy/user/‹uid›) is the last fallback, used only when no URI SAN is present.

Two identities are compared in whichever vocabulary they share: tenant UUIDs when both carry one, organisations when both carry one. A pair with no shared vocabulary — a SPIFFE-only caller against an old-chain device, or the reverse — is not a match, because no mapping exists between a tenant UUID and an int32 organisation and answering "close enough" is exactly what a cross-tenant caller would need.

Legacy tokens that carry no org_id claim (user enrollment only) produce a CSR with a CommonName only — no URI SAN — so existing enrollments continue to work without re-authentication.

The cloud certificate service validates the URI SAN against the enrollment-token or mTLS identity at issuance time.

When the enrollment token carries a tenant_uuid claim, a second URI SAN is added alongside the urn:wendy SAN:

EntityTenant SPIFFE URI SAN format
Device / agentspiffe://wendy.sh/tenant/‹uuid›/service/asset-‹assetID›
User (CLI)spiffe://wendy.sh/tenant/‹uuid›/service/user-‹userID›

Cloud refuses to sign a relay grant unless the CSR carries exactly this SPIFFE principal. The principal kind is always service, never device: cloud relays every client leaf through certificate service's service-identity profile, which would refuse a profile-kind mismatch. That profile is also the one that consults the tenant domain allow-list, so these CSRs stay URI-SAN-only — any dNSName fails the mint.

The urn:wendy SAN is retained rather than replaced. It is what the agent's org-equality gate reads out of a peer certificate, and a SPIFFE principal names a tenant UUID rather than the int32 org that gate compares, so dropping the urn would silently disarm org enforcement across the fleet.

Organizations with no pki tenant receive no tenant_uuid claim and enroll exactly as before — the absence of the claim is never an error.

› Certificate refresh: the refresh path derives identity from the › already-stored certificate rather than an enrollment token, so it has no › tenant_uuid to read and adds no SPIFFE SAN. Only initial enrollment does.

Server certificate verification

The CLI verifies device server certificates on all mTLS connections (BLE, LAN gRPC, and cloud tunnel). Verification includes:

  1. Chain validation — The device's server certificate is validated against the CA chain from the CLI's auth session. ML-DSA chain certificates are handled specially since Go's crypto/x509 cannot parse them.

  2. Organization matching — The server certificate's Wendy org ID is extracted and compared against the CLI's expected org ID. If the device belongs to a different organization than the CLI session, the connection is rejected with an OrgMismatchError. For BLE connections, the CLI automatically retries with a matching certificate from another org if one is available.

  3. Exact device identity (ServerVerifyOpts.ExpectedIdentity) — Required on every enrolled-device mTLS connection, including BLE and MCP Cloud connections. Before connecting, the caller must supply the expected identity from authenticated Cloud inventory, trusted enrollment, or a saved device binding. The certificate must name that exact device. Tenant SPIFFE principals are compared exactly; supported older urn:wendy:org:<org>:asset:<asset> and sh/wendy/<org>/<asset> identities still require the expected organization and asset to match. A missing expectation, a certificate without a device identity, and a different device in the same tenant are rejected. There is no implicit legacy grace mode. This check runs inside tls.Config.VerifyConnection, including on resumed TLS sessions.

  4. SPKI pinning — On first mTLS connection to a device — over BLE, LAN gRPC, or the cloud tunnel — its SPKI (Subject Public Key Info) fingerprint is pinned in ~/.wendy/known_devices.json, keyed by the certificate's Wendy asset identity. A later connection presenting a different key while the previously pinned certificate is still within its validity window is hard-refused (a PinMismatchError aborts the handshake): a renewal replaces an expiring certificate, it does not race one that is still live, so an unexplained key change during that window is treated as a MITM signal, not a warning. Once the pinned certificate has expired, a new key is ordinary rotation — accepted silently, and the pin is updated to the new fingerprint.

Device-to-device peer verification (UUID pin)

When one device dials another by its device UUID, the agent runs VerifyPeerDevice after the chain check. The peer leaf must carry exactly one tenant SPIFFE device principal (spiffe://wendy.sh/tenant/<tenant-uuid>/device/<device-uuid>), its tenant must equal the calling device's own tenant, and its device UUID must equal the roster entry for the dialed name. There is no grace mode: a calling device with no tenant identity of its own refuses every device peer. The dialed address is a routing hint only and is not part of the check. NewClientTLSConfigExpectingPeer selects this strict rule whenever the peer identifier is a UUID.

Mesh peer certificates must be non-CA leaves with explicit clientAuth usage. Missing EKU and anyExtendedKeyUsage alone are refused. LAN QUIC and native mesh TLS apply this peer profile in both TLS roles and recheck restored peer certificates on session resumption. The mesh peer profile does not additionally require serverAuth; issuer certificates may still omit EKU.

A legacy asset-ID string selects the older asset pin: the certificate must identify the expected asset, and its scope must match the calling device's own scope when that scope is known. Only this legacy path permits an unknown calling scope; it still requires the exact asset identity and a valid certificate chain.

Wendy Net verifies the exact enrolled device identity when connecting to a peer. Devices must belong to the same organization. Operators in that organization can also verify a target device when delivering builds.

Device identity pinning (default device)

An enrolled device needs a trusted expected identity before its first mTLS connection. Cloud connections use the selected inventory row's PKI identity (or its legacy organization/asset identity). wendy cloud discover seeds named device bindings in ~/.wendy/config.json under devicePins. A different LAN or BLE hostname needs its own saved binding from verified enrollment; discovery aliases do not establish that relationship. Trusted enrollment or an existing saved device pin can also supply it. The verifier never learns the expected identity from whichever server answers the dial.

BLE uses the selected hostname to look up an existing binding. An advertisement can select an existing constraint but cannot create one. If no binding exists, the CLI refuses the enrolled-device connection: refresh the trusted Cloud inventory or complete explicit enrollment through a trusted setup connection. Successful CLI and desktop enrollment reconnect with the freshly minted expected identity before saving its binding under the selected hostname and enrollment name. A BLE-only device whose advertised name has no matching saved binding cannot use authenticated management until that binding is available. Explicit enrollment can connect to an unpinned plaintext setup endpoint only after it reports that it is unprovisioned. Existing saved identities cannot use that path. Local setup sockets remain separate trust boundaries; none bypasses the enrolled-device verifier for ordinary management.

After an identity-checked connection, the CLI may record the verified identity under the device's other names and refresh its certificate-key pin. A saved binding records the organization, issuing Cloud, asset ID, and tenant SPIFFE principal when present. Every later connection enforces the same device identity during the TLS handshake.

The pin is deliberately not a certificate fingerprint — a device legitimately rotates and re-enrolls certificates, and that must not look like an attack. What trips it is a change of who is answering:

ObservedResult
Same org + cloud + asset (renewed or re-enrolled cert)Connects normally
Different org or cloud hostRefused, no prompt
Same org + cloud, different asset idRefused, no prompt — the hostname now resolves to a different machine, or the device was wiped and re-enrolled as a new asset
No mTLS identity at all, on a hostname that was pinnedRefused, no prompt — the device may have been unenrolled, reflashed, or reset, or another machine may have taken its name
No expected device identity, hostname never pinnedEnrolled-device mTLS is refused; establish a trusted inventory or enrollment binding first

The asset id is read only from a certificate that passed chain and org verification, so an impostor cannot assert its way past the pin. On the dial ladder, a wrong-device rejection aborts the whole ladder immediately — no further certificate or port is tried — and a hostname that carries any pin at all is never offered the unauthenticated plaintext rung, regardless of what its (attacker-controlled) mDNS TXT records claim about it.

Every refusal above reads identically whether the CLI is running interactively, under --json, or non-interactively — there is deliberately no "trust this identity anyway?" prompt. A MITM warning that can be dismissed gets dismissed, and the person who could actually distinguish a legitimate replacement from an attack is rarely the one staring at a prompt mid-command. The one way past a refusal is a separate, deliberate act:

wendy device unpin <hostname>
wendy device unpin spiffe://wendy.sh/tenant/<uuid>/device/<id>
wendy device unpin urn:wendy:org:<org>:asset:<id>

This clears the local pin only — it never dials the device, so it works even when the device is offline, wiped, or gone. Before the next enrolled-device connection, refresh the trusted Cloud inventory or establish a new enrollment binding. Clearing a pin does not authorize accepting whichever certificate answers next. Naming a device explicitly with wendy device set-default <hostname> also clears its saved pin; it still needs a trusted expected identity to reconnect over mTLS.

Both forms are accepted because the two stores are keyed differently. The identity-change refusals above name a hostname, and the hostname form clears it (a pin records its device's principal on the first connect after the SPIFFE cutover, which is how the hostname form still reaches the SPKI entry). The SPKI refusal (point 4 above) can only name the certificate identity, because that is what known_devices.json is keyed by — the tenant SPIFFE principal for a Wendy-issued device, the legacy URN for an old chain and there is often no hostname to offer: wendy device list and the device picker dial the device's IP, and an agent that never advertises orgid in its mDNS records leaves nothing locally that maps a name to an asset. Copy the identity out of the refusal and pass it back — it clears the SPKI entry and any devicePins entry naming the same asset.

Unpinning by hostname also clears pins filed under the device's other names (the cloud roster's asset name, its wendy net name), because one device is legitimately pinned under several — but only when those pins name the same organisation and asset. Those alternate names come from mDNS, which is unauthenticated, so a pin naming a different asset is a different device's pin and is left alone. Unpinning a local VM by its alias, wendy device unpin vm:<name>, clears only that VM's pin, never the 127.0.0.1 pin every other loopback address shares. Whatever is cleared is printed, one line per entry, so an unpin never removes trust state silently.

Re-enrolling after an intentional reset or organization move

wendy device unenroll on a reachable device clears the identity this CLI saved for it once the device confirms its reset, even when the Cloud cleanup that follows fails: the device can no longer present that identity. Cloud-only unenrollment (--cloud-only, wendy cloud device unenroll) never contacts or resets the device, so it keeps the pin. So does a reset, reflash, or organization move done any other way, or unenrollment run from another machine. In those cases, clear the old local pin before retrying enrollment:

wendy device unpin wendyos-ccr1.local
wendy device enroll --device wendyos-ccr1.local

Use the hostname printed in the refusal. A pinned device whose plaintext port answers while no mTLS endpoint does is refused with exactly this guidance, because that is what an unprovisioned agent looks like. If another of its addresses has no agent at all, the refusal also notes that the answering address may be a stale DNS or mDNS record for another machine; keep the pin in that case. When nothing answers at all, the refusal says unpinning is not the fix: that is a reachability problem, not an identity one. The CLI can only tell these cases apart by probing with a client certificate. When it holds none for the device (signed out, for example), the refusal says no authenticated connection could be attempted; run wendy auth login and retry to get the guidance for your case. Unpinning does not enroll the device or delete its cloud asset. If unenrollment reported a cloud cleanup failure, run the wendy cloud device unenroll command it printed, or finish that cleanup in the Wendy Cloud dashboard. Until then Cloud still lists the device, and commands that read that list pin it again; the unenroll output prints the wendy device unpin command that clears such a pin. If the identity change was unexpected, keep the pin and verify the device first; check wendy auth login if this CLI is missing the organization's credentials.

Pin sources and precedence

A pin's source field records how the CLI learned it:

SourceWritten byTrust basis
lanRecording or refreshing an already identity-checked local connectionIts trusted expected device identity plus a matching verified certificate
cloudThe org's asset roster, fetched over an authenticated cloud session (e.g. wendy cloud discover seeds a pin for every named asset the roster returns)The org's cloud vouching for the (name, org, asset) binding

Pins written before sources were tracked carry an empty source and are treated as lan.

A cloud write is authoritative and overwrites whatever was pinned for that name, lan-sourced or not — that is how cloud-known devices obtain their expected identity before the CLI meets them on the network (see below). The one exception is a tenant session's roster meeting a pin that already holds a different tenant principal, which it leaves alone (see Cloud pin seeding). The reverse never holds: a LAN sighting cannot upgrade or override a cloud pin, and specifically:

  • A historical pin without an asset or principal cannot supply an expected device identity. Refresh it from trusted Cloud inventory or enrollment before connecting. An ordinary LAN connection cannot discover the missing binding.
  • An asset-less cloud pin is never displaced by a lan pin in a way that would erase an existing exact-identity constraint on that name — cloud authority decides which binding to believe, and applying it is worthless if the result is a name constrained to no asset at all.

An enrolled agent whose certificate carries no device identity is rejected during TLS verification, regardless of the pin source.

Device names and routing addresses

The expected identity comes from the saved binding for the selected name. A hostname, Cloud inventory name, and mesh name may refer to the same device, but an unauthenticated discovery record cannot establish that relationship or replace an existing binding. Cloud inventory authenticates its own names. Verified enrollment saves the selected hostname and the chosen enrollment name after the certificate is checked.

Picker selections, discovery probes, fleet operations and reconnects retain the selected name independently of the IP used to reach it. IP addresses found through discovery are routing hints; they do not become authentication keys merely because a connection used them. Explicit enrollment may connect to a device confirmed to be unprovisioned, including through the picker. Ordinary management still requires a saved expected identity.

Cloud pin seeding

A hostname without a saved device identity cannot make an enrolled-device mTLS connection. Seeding pins from Cloud supplies that identity for devices the authenticated organization already knows about: whenever the CLI reads a trusted roster, it records the named assets' expected identities before dialing them. The subsequent certificate must match that binding; the server cannot establish the binding by answering first.

A tenant (UUID) session's roster records each asset's device principal, taken from its PKI device binding when it has one. It replaces pins that hold no principal, such as the numeric pins an earlier Cloud session left behind, but never a pin that holds a different principal. That pin names a device the CLI already verified, or a binding an earlier roster made, and a Cloud name that now belongs to another asset stays refused until wendy device unpin. Cloud connections fetch the roster too, so replacing the pin would let the retry of a refused connection reach the name's new holder. A name that two assets share is not seeded, because Cloud lookups refuse it as ambiguous. Two lookups do not seed at all: the offline re-query that explains why a name was not found, and unenrollment, which deletes the asset it finds.

CA key rollover

The trust bundle may contain multiple CA certificates sharing the same subject DN. This is normal during a CA key rollover, where an old CA and a new CA temporarily coexist in the bundle. The agent's ML-DSA client certificate verifier (verifyMLDSAClientCert) tries every CA whose subject DN matches the client certificate's issuer DN. Verification succeeds as soon as any matching CA validates the certificate. If all matching CAs fail, the error from the last attempted CA is returned. If no CA in the pool has a matching subject DN, the verifier returns a "client certificate issuer not found in trusted CA pool" error.

Clock skew and the NotBefore floor

A device that reboots without network connectivity (e.g. a power cycle with no WiFi) may not have synchronised its clock via NTP before the mTLS server starts. With an unsynchronised clock that predates the certificates, every incoming client certificate would be rejected as "not yet valid", silently making the mTLS port unusable.

To handle this, wendy-agent reads the NotBefore timestamp from the device's own provisioning certificate at startup and passes it to the verifier as a time floor. During peer-certificate verification the effective time is:

effectiveNow = max(time.Now(), provisioningCert.NotBefore)

# and, only when the real clock is still behind that floor, advanced far
# enough to admit a cert issued moments after provisioning — but never
# further than 24h past the floor:
if time.Now() < provisioningCert.NotBefore:
    effectiveNow = max(effectiveNow,
                       min(peerCert.NotBefore, provisioningCert.NotBefore + 24h))

The 24h cap is what keeps the floor from becoming a blank cheque: on a device whose clock never synced, a peer certificate dated further ahead than that is still rejected.

effectiveNow is used only for the leaf certificate's NotBefore check — on both the standard (RSA/ECDSA) path, via x509.VerifyOptions.CurrentTime, and the ML-DSA path. Certificate expiry (NotAfter) and CA-certificate validity are always checked against the real system clock, so the floor cannot mask a genuinely expired certificate or make an immature CA appear valid. Pass a zero time.Time to disable the floor.

When the device clock is behind the floor at startup, wendy-agent logs a WARN that includes the device clock, the floor, and how far behind the clock is. If the provisioning certificate cannot be parsed, the floor is zero (disabled) and a WARN notes that NTP clock-skew protection is off. Once NTP synchronises the clock the discrepancy disappears on its own.

The systemd unit also orders the agent after time-sync.target (After=/Wants=) so NTP synchronisation is attempted as early as possible; the floor is the primary guard and does not depend on that ordering.

For additional clock resilience, the agent uses Roughtime — a cryptographically-signed time protocol — to obtain a trusted timestamp from multiple public servers. Roughtime sync runs on startup and periodically thereafter, advancing the system clock when the verified time is ahead of the local clock.

When connecting to a device, the CLI automatically checks for clock skew. If the device clock lags by more than 2 minutes, the CLI fetches a signed Roughtime proof and relays it to the device, which verifies the signature and advances its clock. The CLI's own clock is never sent as authoritative time — only used to decide whether to relay. The CLI can also broadcast Roughtime time to nearby devices via wendy device sync-time.

Avahi advertisement

After provisioning, wendy-agent updates /etc/avahi/services/wendyos-mdns.service to set the _wendyos._udp service block's port to the mTLS port and adds a tls=true TXT record. The CLI reads this record during device discovery to select the mTLS connection path.

Artifact signing key (DefaultVerifier)

Separate from the mTLS PKI, the agent embeds an ML-DSA65 public key (sigverify.DefaultVerifier) used solely to verify the authenticity of agent update binaries delivered via UpdateAgent. This key is a build-time constant and is distinct from provisioning certificates.

A companion per-org publisher key (currently a disabled placeholder, sigverify.Disabled()) is used to verify container images in RunContainer. This key is sourced from provisioning/PKI at runtime and is specific to each organisation's image artifacts.

Both keys are currently empty stubs; verification becomes active once the cross-repo signing pipeline is deployed and real keys are embedded.

On this page