Authentication Model
Clementine implements a role-based authentication model where different certificates grant different access levels.Certificate Roles
| Certificate | Purpose | Access Level |
|---|---|---|
| CA Certificate | Root of trust for all certificates | Signs all entity certificates |
| Server Certificate | TLS encryption for gRPC servers | Enables encrypted connections |
| Client Certificate | Entity’s internal method authentication | Internal RPC methods only |
| Aggregator Certificate | Aggregator’s authenticated access | Verifier and operator methods |
Access Control Rules
Verifier/Operator Services:- Verifier/Operator methods can only be called by the aggregator using
aggregator_cert_path - Internal methods can only be called by the entity’s own client using
client_cert_path
- Does not enforce client certificate authentication
- Uses TLS for encryption only
- Verifiers and operators connect without client certificates
Certificate Generation
Automated Script
Clementine provides a script to generate all required certificates for testing:Generated Directory Structure
Certificate Generation Steps
The script performs the following operations:Create Certificate Authority (CA)
Generates a self-signed CA certificate:The CA will sign all other certificates, establishing the trust chain.
Generate Server Certificate
Creates server certificate for TLS encryption:Includes Subject Alternative Names (SANs) for:
localhost*.docker.internal127.0.0.1172.17.0.1
Configuration
Verifier/Operator Configuration
Aggregator Configuration
Environment Variables
Certificate paths can also be configured via environment variables:mTLS Handshake Flow
Security Best Practices
Development vs. Production
Development/Testing:- ✅ Use script-generated self-signed certificates
- ✅ Automatic generation if certificates missing
- ✅ localhost and Docker networking support
- ⚠️ Use certificates from a trusted Certificate Authority
- ⚠️ Never use self-signed certificates
- ⚠️ Implement certificate rotation policy
- ⚠️ Use proper DNS names (not IP addresses)
Private Key Security
Key protection measures:- Store private keys with restricted permissions:
chmod 600 *.key - Use separate keys per environment (dev, staging, production)
- Rotate keys regularly (e.g., every 90 days)
- Consider hardware security modules (HSMs) for production
- Encrypt keys at rest using secrets management systems
Certificate Rotation
Network Security
Firewall Rules:- Restrict gRPC ports (default 50051) to known IP ranges
- Use VPNs or private networks for entity communication
- Block public access to verifier/operator ports
- Enable rate limiting on gRPC endpoints
- Monitor certificate expiration dates
- Log all authentication failures
- Implement intrusion detection systems
Troubleshooting
Certificate Verification Failed
Client Certificate Rejected
- Check
aggregator_cert_pathmatches aggregator’s certificate - Verify certificate hasn’t expired
- Ensure certificate was signed by the correct CA
Certificate Expired
Hostname Verification Failed
Code References
- Certificate generation script:
scripts/generate_certs.sh - gRPC server setup:
core/src/rpc/ - Client authentication:
core/src/rpc/aggregator.rs - Configuration parsing:
core/src/config/