Repository navigation
feat(agent): import CA issued certificate chains as did:x509 - #1823
Merged
Merged
Conversation
Adds Phase A of did:x509 support on top of the agent-controller import endpoint (credebl/agent-controller#473): - POST /orgs/:orgId/agents/did/x509/import forwards a certificate chain, the leaf private key and optional policies to the agent and records the resulting DID in org_dids. Re-importing the same chain returns the existing record. isPrimaryDid defaults to false. - GET /orgs/:orgId/agents/did/x509/chain/:did returns the chain the agent stores with the DID. - An agent without the did:x509 route is reported as needing an upgrade instead of a bare 404. The private key and passphrase are only forwarded to the agent. To keep them out of the logs, CommonService no longer logs the request body and authorization header of failed agent calls; this also stops agent API keys from being logged on every failed POST, GET and PATCH. Signed-off-by: Ajay Jadhav <ajay@ayanworks.com>
|
Caution Review failedThe pull request is closed.
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. |
The certificate is the source of truth for the key type. Override the request keyType before forwarding to the agent so callers that omit it or use a different spelling still import correctly, and persist isImported for records created through the import endpoint. Signed-off-by: Ajay Jadhav <ajay@ayanworks.com>
|
ajile-in
marked this pull request as ready for review
November 7, 2026 06:25
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



Summary
Phase A of did:x509 support in the platform, on top of the agent-controller import endpoint in credebl/agent-controller#473. An organization can import an existing CA issued certificate chain and its leaf private key as a
did:x509in its agent wallet.Draft until credebl/agent-controller#473 is merged and released. The request and response shapes follow that PR and may still change.
New endpoints
POST /orgs/:orgId/agents/did/x509/importcertificateChain[](leaf first),privateKey, optionalpassphrase,policies[]anddidto the agent'sPOST /dids/x509/import, then records the DID inorg_dids. Returns the DID record pluskeyIdandverificationMethodId.GET /orgs/:orgId/agents/did/x509/chain/:didGET /dids/x509/chain/{did}).Behaviour
isPrimaryDiddefaults to false. When true, the other DIDs are made non-primary and the ledger is set to not applicable, ascreateDiddoes.org_didsrecord instead of a 409, matching the agent's idempotent import.ECONNREFUSED) is still reported as unreachable.subjectneedsfields,sanneedssanTypeandvalue,ekuandfulcio-issuerneedvalue).org_didsalready holdsdidanddidDocument.Secrets in logs
The private key and passphrase are forwarded to the agent and never stored.
CommonServiceused to log the whole Axios error of a failed POST, GET or PATCH, which serialises the request body and theauthorizationheader. Any agent error on import would have logged the private key, and today every failed agent call already logs the agent API key. The error log now dropsconfig.dataandconfig.headers. A test covers it, and it fails without the fix.Not in this PR
AFJ_VERSIONto a controller release that includes fix: create schema api response #473.Testing
jest --config jest.ci.config.js: 303 passed.dependency-integrity.spec.tsfailed locally only because the worktree reused another checkout'snode_modules. This branch doesn't changepackage.jsonor the lockfile.agent-serviceandapi-gateway.createDid.Verification against the OpenBao branch
Run under test: agent-controller
177ca83(feat/openbao-kms, OpenBao enabled), platform90c167cf(
feat/did-x509-import), studio605006a1(fix/x509-certificates-platform-enum).import-did-x509over NATS succeeded twice with the sameorg_dids.id, same DID, and sameob_key id; zeroduplicate rows and zero new Transit keys.
get-did-x509-chainreturned{ did, x509chain: [leaf, root] }.create-x509-certificatepassed for P-256 and Ed25519; both self-signed certificates verify.import-x509-certificatepassed with base64 DER material and with a PEM private key and nokeyType(theplatform derives the type from the certificate). Import records now persist
isImported: true.subjectunlesssubjectPublicKeyis supplied (Credo self-signed rule); theworking request does.
This exercises the platform service layer against a real agent-controller/OpenBao stack. A full api-gateway +
Keycloak HTTP/UI run is not covered here; see
docs/openbao-e2e.mdin agent-controller for the run record andremaining gate.