Skip to content
Open
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -171,13 +171,13 @@ boundary without touching the service layer.
| Server certificate issuance | File-backed self-signed CA (`ca.server.type: self`) or external RFC 8555 ACME CA such as Let's Encrypt (`ca.server.type: acme`) for the `serverCsrPEM` path, plus BYOC (`serverCertificatePEM` + chain). Exactly one of CSR/BYOC per registration/renewal. Issuance runs through a certificate-order lifecycle: `CreateOrder` (at registration/renewal submission) returns the provider's domain-control challenges, which are relayed verbatim to the domain owner — ANS never writes DNS or serves challenge files on their behalf; `FinalizeOrder` (at verify-acme, gated on a verified challenge artifact) returns the cert, or `ErrOrderPending` for asynchronous providers (ACME CAs such as Let's Encrypt), in which case re-POSTing verify-acme re-drives the order. | `port.ServerCertificateIssuer` |
| DNS verification | `noop` (quickstart; accepts any state) and `lookup` (real miekg/dns queries with TXT / TLSA / HTTPS / SVCB support; TLSA responses carry the resolver's DNSSEC AuthenticatedData bit through to the TL attestation as `dnsRecordsProvisioned[].dnssecVerified`) | `port.DNSVerifier` |
| HTTP-01 challenge verification | Plain-HTTP fetch of the owner-published challenge artifact (`/.well-known/acme-challenge/<token>` by default). The verify-acme gate passes when either the DNS-01 TXT record or the HTTP-01 resource verifies. | `port.HTTPChallengeVerifier` |
| Signing keys | File-based ECDSA P-256 PEM | `port.KeyManager` |
| Signing keys | File-based ECDSA P-256 PEM, or existing AWS KMS keys (`keys.type: aws-kms`) | `port.KeyManager` |
| Storage (RA) | SQLite | `port.AgentStore`, `port.CertificateStore`, `port.RenewalStore`, `port.OutboxStore`, `port.UnitOfWork` |
| Storage (TL) | SQLite + Tessera POSIX tile storage | `tl/event` codec interfaces |
| Producer-key trust store | SQLite + `/internal/v1/producer-keys` admin CRUD; YAML `producerKeys[]` for bootstrap seeding | `producerkey.Store` and `producerkey.AdminStore` |
| Scheduler | Go goroutines + `time.Ticker` | (in-process) |

Cloud-KMS, cloud-DB (Postgres / managed RDBMS), and managed-DNS
Other cloud-KMS, cloud-DB (Postgres / managed RDBMS), and managed-DNS
adapters are good contribution-shaped opportunities — they slot in
at the port boundary.

Expand Down
56 changes: 53 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -268,12 +268,62 @@ of them at the port boundary without touching the service layer.
| Identity cert issuance | File-backed self-signed CA | Cloud KMS-backed CA |
| Server cert issuance | Self-signed CA + BYOC PEM | ACME / public CA / BYOC PEM |
| DNS verification | `noop` and `lookup` (real miekg/dns queries with DNSSEC AD-bit propagation) | `lookup` against your authoritative DNS |
| Signing keys | File-based ECDSA P-256 | Cloud KMS adapter |
| Signing keys | File-based ECDSA P-256 | AWS KMS (`keys.type: aws-kms`) |
| Storage | SQLite | Postgres / managed RDBMS |

Cloud-KMS, Postgres, and managed-DNS adapters are
Other cloud-KMS, Postgres, and managed-DNS adapters are
contribution-shaped — see `CONTRIBUTING.md`.

### Signing keys in AWS KMS

`keys.type: aws-kms` signs with existing AWS KMS keys instead of PEM
files. Each key ID the service signs with (`attestation.keyId` on the
TL, `signer.keyId` on the RA) maps to a KMS key ID, key ARN, or alias.
The key ID stays the published name: the RA still sends it as the event
JWS `kid`, and the KMS reference stays inside the process.

```yaml
keys:
type: aws-kms
aws-kms:
region: us-east-1 # optional; defaults to the credential chain's region
keys:
ans-tl-attestation: alias/ans-tl-signing
```

- Create each key as `ECC_NIST_P256` with key usage `SIGN_VERIFY`. The
service checks spec, usage, and state at startup and does not create
keys.
- Credentials come from the standard AWS credential chain (environment,
shared config, IAM role). The service needs `kms:DescribeKey`,
`kms:GetPublicKey`, and `kms:Sign` on its own key only:

```json
{
"Version": "2012-10-17",
"Statement": [{
"Effect": "Allow",
"Action": ["kms:DescribeKey", "kms:GetPublicKey", "kms:Sign"],
"Resource": "arn:aws:kms:us-east-1:111122223333:key/<key-id>"
}]
}
```

- The RA does not write `ans-ra-signer.pub` when its key is in KMS.
Take the PEM for the TL's `producerKeys` from KMS instead:

```bash
{ echo "-----BEGIN PUBLIC KEY-----"
aws kms get-public-key --key-id alias/ans-ra-signer \
--query PublicKey --output text | fold -w 64
echo "-----END PUBLIC KEY-----"; } > ans-ra-signer.pub
```

- Mapping a key ID to a different KMS key changes the public key that
verifiers and the TL producer-key store trust. Treat it as a key
rotation. The service resolves an alias to its key ARN at startup, so
re-pointing the alias takes effect on the next restart.

## Development

```bash
Expand Down Expand Up @@ -306,7 +356,7 @@ lookup, Merkle tiles • Producer-key admin CRUD
verifies both receipts and status tokens • `ans-dns` dev DNS server
with `install` / `clear` for verify-dns end-to-end testing.

Follow-up opportunities (community): cloud-KMS / Postgres /
Follow-up opportunities (community): other cloud-KMS / Postgres /
managed-DNS adapters, real ACME DNS-01 verifier wiring, additional
schema versions.

Expand Down
30 changes: 29 additions & 1 deletion cmd/ans-ra/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ func run(cfgPath string) error {
identityLinks := sqlite.NewIdentityLinkStore(db)

// Crypto.
km, err := keymanager.NewFileKeyManager(cfg.Keys.File.Path)
km, err := buildKeyManager(ctx, cfg.Keys, logger)
if err != nil {
return fmt.Errorf("open key manager: %w", err)
}
Expand Down Expand Up @@ -490,6 +490,34 @@ func run(cfgPath string) error {
}
}

// keyManager is the configured key manager, including the EnsureKey
// call run makes at startup.
type keyManager interface {
port.KeyManager
EnsureKey(ctx context.Context, keyID, algorithm string) (string, error)
}

// buildKeyManager builds the key manager selected by keys.type.
func buildKeyManager(ctx context.Context, k config.Keys, logger zerolog.Logger) (keyManager, error) {
if k.Type == "aws-kms" {
client, err := keymanager.NewAWSKMSClient(ctx, k.AWSKMS.Region)
if err != nil {
return nil, err
}
km, err := keymanager.NewAWSKMSKeyManager(client, k.AWSKMS.Keys, keymanager.WithAWSKMSLogger(logger))
if err != nil {
return nil, err
}
logger.Info().Str("region", client.Options().Region).Int("keys", len(k.AWSKMS.Keys)).Msg("AWS KMS key manager ready")
return km, nil
}
km, err := keymanager.NewFileKeyManager(k.File.Path)
if err != nil {
return nil, err
}
return km, nil
}

// buildLogger configures zerolog per cfg.
func buildLogger(cfg config.Log) zerolog.Logger {
level, err := zerolog.ParseLevel(cfg.Level)
Expand Down
30 changes: 29 additions & 1 deletion cmd/ans-tl/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ func run(cfgPath string) error {
// signer, outer envelope attestation JWS, SCITT receipts, and
// status tokens. Matches the reference TL's deployed topology
// (production `/root-keys` advertises exactly one key).
km, err := keymanager.NewFileKeyManager(cfg.Keys.File.Path)
km, err := buildKeyManager(ctx, cfg.Keys, logger)
if err != nil {
return fmt.Errorf("key manager: %w", err)
}
Expand Down Expand Up @@ -328,6 +328,34 @@ func run(cfgPath string) error {
}
}

// keyManager is the configured key manager, including the EnsureKey
// call run makes at startup.
type keyManager interface {
port.KeyManager
EnsureKey(ctx context.Context, keyID, algorithm string) (string, error)
}

// buildKeyManager builds the key manager selected by keys.type.
func buildKeyManager(ctx context.Context, k config.Keys, logger zerolog.Logger) (keyManager, error) {
if k.Type == "aws-kms" {
client, err := keymanager.NewAWSKMSClient(ctx, k.AWSKMS.Region)
if err != nil {
return nil, err
}
km, err := keymanager.NewAWSKMSKeyManager(client, k.AWSKMS.Keys, keymanager.WithAWSKMSLogger(logger))
if err != nil {
return nil, err
}
logger.Info().Str("region", client.Options().Region).Int("keys", len(k.AWSKMS.Keys)).Msg("AWS KMS key manager ready")
return km, nil
}
km, err := keymanager.NewFileKeyManager(k.File.Path)
if err != nil {
return nil, err
}
return km, nil
}

func buildLogger(cfg config.Log) zerolog.Logger {
level, err := zerolog.ParseLevel(cfg.Level)
if err != nil {
Expand Down
6 changes: 6 additions & 0 deletions config/ra-local.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,12 @@ keys:
type: file
file:
path: "./data/ra/keys"
# AWS KMS instead of PEM files: set type to aws-kms and map the
# signing key ID to an existing ECC_NIST_P256 SIGN_VERIFY key.
# aws-kms:
# region: us-east-1
# keys:
# ans-ra-signer: alias/ans-ra-signer

store:
type: sqlite
Expand Down
6 changes: 6 additions & 0 deletions config/tl-local.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,12 @@ keys:
type: file
file:
path: "./data/tl/keys"
# AWS KMS instead of PEM files: set type to aws-kms and map the
# signing key ID to an existing ECC_NIST_P256 SIGN_VERIFY key.
# aws-kms:
# region: us-east-1
# keys:
# ans-tl-attestation: alias/ans-tl-signing

store:
type: sqlite
Expand Down
15 changes: 15 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ module github.com/agentnameservice/ans
go 1.26.0

require (
github.com/aws/aws-sdk-go-v2 v1.47.8
github.com/aws/aws-sdk-go-v2/config v1.33.16
github.com/aws/aws-sdk-go-v2/service/kms v1.62.5
github.com/coreos/go-oidc/v3 v3.21.0
github.com/cyberphone/json-canonicalization v0.0.0-20241213102144-19d51d7fe467
github.com/fxamacker/cbor/v2 v2.10.0
Expand All @@ -29,6 +32,18 @@ require (
)

require (
github.com/aws/aws-sdk-go-v2/credentials v1.20.16 // indirect
github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.20.8 // indirect
github.com/aws/aws-sdk-go-v2/internal/configsources v1.5.11 // indirect
github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.8.11 // indirect
github.com/aws/aws-sdk-go-v2/internal/v4a v1.5.11 // indirect
github.com/aws/aws-sdk-go-v2/service/internal/accept-encoding v1.13.24 // indirect
github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.14.11 // indirect
github.com/aws/aws-sdk-go-v2/service/signin v1.12.4 // indirect
github.com/aws/aws-sdk-go-v2/service/sso v1.39.4 // indirect
github.com/aws/aws-sdk-go-v2/service/ssooidc v1.44.4 // indirect
github.com/aws/aws-sdk-go-v2/service/sts v1.51.9 // indirect
github.com/aws/smithy-go v1.28.8 // indirect
github.com/cenkalti/backoff/v5 v5.0.3 // indirect
github.com/cespare/xxhash/v2 v2.3.0 // indirect
github.com/dustin/go-humanize v1.1.0 // indirect
Expand Down
30 changes: 30 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
@@ -1,5 +1,35 @@
filippo.io/edwards25519 v1.1.0 h1:FNf4tywRC1HmFuKW5xopWpigGjJKiJSV0Cqo0cJWDaA=
filippo.io/edwards25519 v1.1.0/go.mod h1:BxyFTGdWcka3PhytdK4V28tE5sGfRvvvRV7EaN4VDT4=
github.com/aws/aws-sdk-go-v2 v1.47.8 h1:fuClo7Un+Bi0EDTnSIPWxVEoJcze+wkGzNA4Vo3jRcQ=
github.com/aws/aws-sdk-go-v2 v1.47.8/go.mod h1:I8lFSH4MGrZiw2m7miCrRYHsgpC1+HW8uiVGOiPYPcw=
github.com/aws/aws-sdk-go-v2/config v1.33.16 h1:fKRsu9Pj2IPIHzTcUdWB7JHY34q9+4XEGCy7WfZaLV4=
github.com/aws/aws-sdk-go-v2/config v1.33.16/go.mod h1:wdEdQ9RBH3fnD/vicCDUIJqv8Ck3zOpxNz8e3/NtkG8=
github.com/aws/aws-sdk-go-v2/credentials v1.20.16 h1:cqRWTY4fcctJGqZedMC1Khu4h2VsgRODUOIZwn39n3Y=
github.com/aws/aws-sdk-go-v2/credentials v1.20.16/go.mod h1:x8JgCOAnbnEVQOLVX6lOtsyTrG2EHgiRNqzku9jiVxA=
github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.20.8 h1:1bCo9/cf7dlTlbrZnz7g1Bki72b5thfuzFZCjdWCfVk=
github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.20.8/go.mod h1:mzPw75GydqddJpfuwYO/ZDIl6xNxKjK86apitdLmvV0=
github.com/aws/aws-sdk-go-v2/internal/configsources v1.5.11 h1:LTxHSJ/rwTFfaXqi5mlKKHJOW+shFB+HQ7NrCa4OQ48=
github.com/aws/aws-sdk-go-v2/internal/configsources v1.5.11/go.mod h1:GF0bVKZVQX4UeUtPmTuWZj3gw0eRCdkVhW0xFnSRLmU=
github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.8.11 h1:DGUM0yztI3Zz5kePulT/mMP/gVZFGTTISUiCcqSQtT0=
github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.8.11/go.mod h1:kbcdJgN9cgSzZlUqsMveDl9IfexJqOzCihXjQXTNaPk=
github.com/aws/aws-sdk-go-v2/internal/v4a v1.5.11 h1:kOHCwgWFyfrz9GqnJct8knQw7Apyl3xHH+OGnome77s=
github.com/aws/aws-sdk-go-v2/internal/v4a v1.5.11/go.mod h1:854cZkT2fdkdrzQklD49uzxkZnajXoelpVNgT/yk4J0=
github.com/aws/aws-sdk-go-v2/service/internal/accept-encoding v1.13.24 h1:jGzHjc2jDx08Rji1JTBtMxuXUDG7muTEw+ExYXqFzPg=
github.com/aws/aws-sdk-go-v2/service/internal/accept-encoding v1.13.24/go.mod h1:uJt75pK2cEyY80F5C+DK9YkCkJWsMkJViHxLYZRHl8Y=
github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.14.11 h1:PO7Tx443ecMI00nIxDrT99DVcbeMBQ6BUtJlDMRnY24=
github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.14.11/go.mod h1:n/9RixikO12YvNomZLP8k4TgUSoEkT1W23QIrpFAPvw=
github.com/aws/aws-sdk-go-v2/service/kms v1.62.5 h1:zLDKVpPR80azmHgG+RHgQr9xGbkHeMFXaa3Me0GR9Vs=
github.com/aws/aws-sdk-go-v2/service/kms v1.62.5/go.mod h1:y1AKPQmIL4psh+C/PhBi3rPPltweFpgwdkld6QNvtgI=
github.com/aws/aws-sdk-go-v2/service/signin v1.12.4 h1:uo84u6f6YatFOBwk3DKM+ToqgVEB0cDjHQLsfrRm44A=
github.com/aws/aws-sdk-go-v2/service/signin v1.12.4/go.mod h1:PCRJucC12nFWle7wRGhSj0cw3OKB84M0EBwTrv34dhg=
github.com/aws/aws-sdk-go-v2/service/sso v1.39.4 h1:qQ97XqrlFGRRhhrcDbeqUVeezamo1a1F7lH4HczU7EA=
github.com/aws/aws-sdk-go-v2/service/sso v1.39.4/go.mod h1:mPM3sWIm0iUGl5OWkR9cG23PRFQ0Ir6y+3Hg0lKBAAE=
github.com/aws/aws-sdk-go-v2/service/ssooidc v1.44.4 h1:tbsL9+L+1SlD2W+9RjL7wD9ZVsxel7QXdQlIWt5tEi8=
github.com/aws/aws-sdk-go-v2/service/ssooidc v1.44.4/go.mod h1:3L2pKVr2e3jaz9C26RXgjBIktSW1D7S0O38LhCdsAYc=
github.com/aws/aws-sdk-go-v2/service/sts v1.51.9 h1:soG/8YBczEJwckK+e4HLt0RzfkvopGrdBjmbghG99Cc=
github.com/aws/aws-sdk-go-v2/service/sts v1.51.9/go.mod h1:We33qfrD3dQRAetZ+9qUH9w+ZjL1gwP2Qvp1YqQDdsk=
github.com/aws/smithy-go v1.28.8 h1:aEmdAq7gVCoGCnvf1NnELlu3I6D/nhqrC321FyFiQkQ=
github.com/aws/smithy-go v1.28.8/go.mod h1:YE2RhdIuDbA5E5bTdciG9KrW3+TiEONeUWCqxX9i1Fc=
github.com/cenkalti/backoff/v5 v5.0.3 h1:ZN+IMa753KfX5hd8vVaMixjnqRZ3y8CuJKRKj1xcsSM=
github.com/cenkalti/backoff/v5 v5.0.3/go.mod h1:rkhZdG3JZukswDf7f0cwqPNk4K0sa+F97BxZthm/crw=
github.com/cespare/xxhash/v2 v2.3.0 h1:UL815xU9SqsFlibzuggzjXhog7bL6oX9BbNZnL2UFvs=
Expand Down
Loading