rusmes-acme
ACME v2 protocol client for automatic TLS certificate management with Let's Encrypt integration.
Features
- ACME v2 Protocol: Full support for RFC 8555 ACME protocol
- Let's Encrypt Integration: Production and staging environments
- Challenge Types:
- HTTP-01: Serve challenges via HTTP server
- DNS-01: Automated DNS TXT record management
- Automatic Renewal: Background task for certificate renewal
- Certificate Management:
- CSR generation (RSA 2048/4096, ECDSA P-256)
- Certificate parsing and validation
- Expiry checking and monitoring
- Hot-reload support
- Storage: Filesystem-based certificate storage with proper permissions
- Extensible: Pluggable DNS provider system
Usage
Basic Example
use ;
async
Automatic Renewal
use ;
async
DNS-01 Challenge
use ;
use async_trait;
// Implement custom DNS provider
async
HTTP-01 Server Integration
The HTTP-01 challenge handler needs to be integrated with your HTTP server:
use Http01Handler;
use Arc;
async
// In your HTTP server setup:
// GET /.well-known/acme-challenge/{token} -> acme_challenge_handler
Configuration
AcmeConfig
Builder Methods
let config = new
.staging // Use Let's Encrypt staging
.challenge_type
.cert_paths
.renewal;
Certificate Types
KeyType
KeyType::Rsa2048- RSA 2048-bit (currently mapped to ECDSA P-256)KeyType::Rsa4096- RSA 4096-bit (currently mapped to ECDSA P-256)KeyType::EcdsaP256- ECDSA P-256 (recommended)
Note: Due to rcgen limitations, RSA key generation currently falls back to ECDSA P-256.
Kubernetes Integration
For Kubernetes deployments, you can use cert-manager annotations:
apiVersion: v1
kind: Service
metadata:
name: rusmes
annotations:
cert-manager.io/issuer: "letsencrypt-prod"
cert-manager.io/cluster-issuer: "letsencrypt-prod"
Or use the built-in ACME client with a persistent volume for certificates:
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: rusmes-certs
spec:
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 1Gi
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: rusmes
spec:
template:
spec:
volumes:
- name: certs
persistentVolumeClaim:
claimName: rusmes-certs
containers:
- name: rusmes
volumeMounts:
- name: certs
mountPath: /etc/rusmes/certs
env:
- name: ACME_EMAIL
value: "admin@example.com"
- name: ACME_DOMAINS
value: "mail.example.com"
Testing
Run the test suite:
Run specific test:
Run with output:
Security Considerations
- Private Key Protection: Private keys are stored with 0600 permissions on Unix systems
- Email Contact: Provide a valid email for Let's Encrypt notifications
- Rate Limits: Use staging environment for testing to avoid hitting production rate limits
- DNS Propagation: DNS-01 challenges wait for propagation before validation
- Certificate Validation: Certificates are validated before use
Rate Limits
Let's Encrypt has the following rate limits:
- Production: 50 certificates per registered domain per week
- Staging: Much higher limits for testing
- Failed Validation: 5 failures per account per hostname per hour
Always use the staging environment during development!
Error Handling
The crate provides detailed error types:
Contributing
When contributing, ensure:
- All tests pass:
cargo test - No warnings:
cargo build 2>&1 | grep warning - Code is formatted:
cargo fmt - Clippy is happy:
cargo clippy
License
This crate is part of the rusmes project and follows the same license.