ans-verify
Trust verification library for the Agent Name Service (ANS).
Overview
This crate implements the ANS trust verification flow, combining DNS lookups, transparency log badge retrieval, and certificate fingerprint comparison to verify agent identities.
Quick Start
use ;
async
Verification Flow
Server Verification
When connecting to an ANS agent server:
- DNS lookup
_ans-badge.{fqdn}(fallback:_ra-badge) for the transparency log URL - Fetch badge from transparency log API
- Validate badge status (Active, Warning, Deprecated allowed)
- Compare server certificate fingerprint to badge attestation
- Compare certificate CN to badge agent host
- Optional: DANE/TLSA verification
Client Verification (mTLS)
When accepting mTLS connections from ANS agent clients:
- Extract FQDN from certificate CN, version from URI SAN
- DNS lookup by FQDN, match badge to certificate version
- Compare identity certificate fingerprint to badge attestation
- Compare ANS name from URI SAN to badge
Configuration
DNS Presets
use AnsVerifier;
let verifier = builder
.dns_cloudflare // or .dns_google(), .dns_quad9()
.build
.await?;
Failure Policies
| Policy | Behavior |
|---|---|
FailClosed |
Reject on any error (default) |
FailOpenWithCache |
Allow if a cached badge exists within max staleness |
DANE/TLSA
use ServerVerifier;
let verifier = builder
.with_dane_if_present // verify TLSA if records exist
// or .require_dane() // fail if no TLSA records
.dane_port // custom port (default: 443)
.build
.await?;
Badge Caching
let verifier = builder
.with_caching // enable Moka-based TTL cache
.build
.await?;
Trusted RA Domains
Restrict badge URL fetches to known transparency log hosts. This prevents DNS-based redirections to attacker-controlled servers:
let verifier = builder
.trusted_ra_domains
.build
.await?;
When configured, badge URLs discovered via DNS TXT records are validated before any HTTP request is made. URLs pointing to hosts not in the set are rejected with TlogError::UntrustedDomain. By default (None), all domains are allowed.
Traits
Implement these traits for custom backends:
DnsResolver
TransparencyLogClient
Testing
Mock implementations are provided behind the test-support feature flag:
[]
= { .., features = ["test-support"] }
use ;
let dns = new;
let tlog = new;
let verifier = builder
.dns_resolver
.tlog_client
.build
.await?;
Feature Flags
| Feature | Description |
|---|---|
rustls |
Enables AnsServerCertVerifier and AnsClientCertVerifier for rustls TLS integration |
test-support |
Exposes MockDnsResolver and MockTransparencyLogClient for use in downstream integration tests |
License
MIT