feat(mtls): add certificate lifecycle API and DB schema (#146)#387
Open
Subhajitdas99 wants to merge 18 commits intoGetBindu:mainfrom
Open
feat(mtls): add certificate lifecycle API and DB schema (#146)#387Subhajitdas99 wants to merge 18 commits intoGetBindu:mainfrom
Subhajitdas99 wants to merge 18 commits intoGetBindu:mainfrom
Conversation
…safe task handling
- Add agent_certificates and certificate_audit_log tables with Alembic migration - Add CertificateData, CertificateIssueParams, CertificateRenewParams, CertificateRevokeParams to protocol/types.py - Add /api/v1/certificates/issue, /renew, /revoke endpoints with local CA signing - Register certificate routes in BinduApplication (opt-in via mtls_enabled setting) Part of GetBindu#146 - mTLS Transport Layer Security
d54f2a6 to
c8bb25b
Compare
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
mtls_enabledsetting.pip install bindu+ zero-config agent still works with zero TLS configuration. This is the infrastructure layer only — the ASGI/Uvicorn SSL context (Standalone Mode) is being handled separately by @Subhajitdas99 in a companion PR.Change Type
Scope
Linked Issue/PR
User-Visible / Behavior Changes
None by default. mTLS is disabled (
mtls_enabled = False) unless explicitly enabled in settings. When enabled, three new endpoints become available:POST /api/v1/certificates/issuePOST /api/v1/certificates/renewPOST /api/v1/certificates/revokeOn first run with mTLS enabled, a local Root CA is auto-generated at
~/.bindu/certs/with no external dependencies.Security Impact
YesYesYesYesYesExplanation:
~/.bindu/certs/ca.keywith no passphrase — acceptable for local dev, operators should replace with Vault PKI or AWS Private CA in production (documented in ADR).x5t#S256claim — a PUT to the Hydra Admin API is made on every issue/renew/revoke.20260322_0001addsagent_certificatesandcertificate_audit_logtables — no changes to existing tables, fully backward compatible.Verification
Environment
Steps to Test
uv run alembic history— confirm20260322_0001appears as the single headpython examples/beginner/beginner_zero_config_agent.py— confirm agent starts normally with no mTLS errors (opt-out default)uv run pytest— confirm existing tests unaffectedmtls_enabled = True: runuv run alembic upgrade head, thenPOST /api/v1/certificates/issuewith a valid CSR — expect 201 + PEM certificate in responsePOST /api/v1/certificates/revoke— confirm statusrevokedinagent_certificatestable and Hydra binding clearedExpected Behavior
alembic historyshows a single clean migration head/issuereturns a signed PEM certificate with SHA-256 fingerprint/revokemarks cert as revoked in DB and removes Hydra binding immediatelyActual Behavior
http://localhost:3773✅alembic historyshows single head20260322_0001✅Evidence
alembic historyoutput confirms clean migration chainHuman Verification
mtls_enabledguard usesgetattrwith fallback — safe ifsecuritysection missing from settings entirely.Compatibility / Migration
YesYes— new optionalsecurity.mtls_enabledflag, defaults toFalseYesuv run alembic upgrade headto createagent_certificatesandcertificate_audit_logtables. No existing tables modified.Failure Recovery
security.mtls_enabled = False(already the default) — certificate routes simply won't registerbindu/server/applications.py— remove_register_certificate_endpoints()call and method/issueand/revokewill return 500 — this is expected and loggedRisks and Mitigations
~/.bindu/certs/ca.keyValueErroron failure — the endpoint returns 500 and logs the error. No partial state is committed.Checklist
uv run pytest) — pytest hook fails withuv: command not foundin pre-commit environment (Windows path issue, unrelated to this PR)