Certificate Backup
Certificate Backup
Section titled “Certificate Backup”Mantis uses mTLS certificates for all inter-component communication. Losing certificates means components cannot authenticate with each other, requiring re-enrollment. This guide covers how to back up and restore certificates safely.
What to Back Up
Section titled “What to Back Up”Certificates follow the *-cert.pem / *-key.pem naming convention in
/etc/mantis/certs/:
| File | Location | Purpose | Sensitivity |
|---|---|---|---|
| CA certificate | /etc/mantis/certs/ca-cert.pem | Root of trust for all components | Public (can be shared) |
| CA private key | /etc/mantis/certs/ca-key.pem | Signs new certificates | Critical — protect this |
| Component certificates | /etc/mantis/certs/<component>-cert.pem | Identity for each component | Public |
| Component private keys | /etc/mantis/certs/<component>-key.pem | Authentication for each component | Sensitive |
Component certificate/key pairs include mandible-cert.pem/mandible-key.pem,
client-cert.pem/client-key.pem (the shared mesh client cert used by Tarsus
agents and Mandible’s orchestration client), and the Thorax-side
server-cert.pem/server-key.pem. Mandible also holds
dispatch-cert.pem/dispatch-key.pem — its dispatch identity (CN “mandible”)
that Thorax trusts for cross-tenant deployment calls. Production stores the RS256
JWT signing pair jwt-private.pem/jwt-public.pem in /etc/mantis/keys/
(a separate directory from /etc/mantis/certs/; include it in any backup that
covers /etc/mantis/certs/).
Backup Procedures
Section titled “Backup Procedures”Manual Backup
Section titled “Manual Backup”# Create a dated backup directoryBACKUP_DIR="/opt/mantis/backups/certs/$(date +%Y%m%d)"mkdir -p "$BACKUP_DIR"
# Copy certificate files and JWT signing keyscp -a /etc/mantis/certs/ "$BACKUP_DIR/"cp -a /etc/mantis/keys/ "$BACKUP_DIR/"
# Set restrictive permissions on the backupchmod -R 600 "$BACKUP_DIR"chown -R root:root "$BACKUP_DIR"
# Verify the backupls -la "$BACKUP_DIR/"diff -r /etc/mantis/certs/ "$BACKUP_DIR/"Encrypted Backup
Section titled “Encrypted Backup”For off-site or cloud storage, encrypt the backup:
# Create a tarball and encrypt with a passphrase# Includes both /etc/mantis/certs/ (mTLS certs) and /etc/mantis/keys/ (JWT signing keys)tar czf - /etc/mantis/certs/ /etc/mantis/keys/ | \ gpg --symmetric --cipher-algo AES256 \ -o "/opt/mantis/backups/certs-$(date +%Y%m%d).tar.gz.gpg"
# Or encrypt with a public key (preferred for automation)tar czf - /etc/mantis/certs/ /etc/mantis/keys/ | \ gpg --encrypt --recipient "ops@example.com" \ -o "/opt/mantis/backups/certs-$(date +%Y%m%d).tar.gz.gpg"Restore from Encrypted Backup
Section titled “Restore from Encrypted Backup”# Decrypt and extractgpg --decrypt "/opt/mantis/backups/certs-20260115.tar.gz.gpg" | \ tar xzf - -C /
# Verify restored filesopenssl x509 -in /etc/mantis/certs/ca-cert.pem -noout -subject -datesAutomated Backup Script
Section titled “Automated Backup Script”#!/bin/bashset -euo pipefail
CERT_DIR="/etc/mantis/certs"KEYS_DIR="/etc/mantis/keys" # JWT RS256 signing pair lives hereBACKUP_BASE="/opt/mantis/backups/certs"RETENTION_DAYS=90DATE=$(date +%Y%m%d-%H%M%S)
# Create backup (certs + JWT keys)mkdir -p "$BACKUP_BASE"tar czf "$BACKUP_BASE/certs-$DATE.tar.gz" \ -C /etc/mantis certs keyschmod 600 "$BACKUP_BASE/certs-$DATE.tar.gz"
# Verify backup integritytar tzf "$BACKUP_BASE/certs-$DATE.tar.gz" > /dev/null
# Clean old backupsfind "$BACKUP_BASE" -name "certs-*.tar.gz" -mtime +$RETENTION_DAYS -delete
echo "Certificate backup completed: $BACKUP_BASE/certs-$DATE.tar.gz"Schedule with cron:
# Weekly certificate backup0 2 * * 0 /opt/mantis/scripts/backup-certs.sh >> /var/log/mantis/cert-backup.log 2>&1CA Key Storage Best Practices
Section titled “CA Key Storage Best Practices”The CA private key deserves extra protection beyond standard backups:
Offline Storage
Section titled “Offline Storage”After initial setup and certificate signing, move the CA key to offline storage:
- Copy the CA key to an encrypted USB drive
- Store the USB drive in a physical safe or secure location
- Remove the CA key from the server (keep only the CA certificate)
- Only bring the CA key online when signing new certificates
Secrets Management
Section titled “Secrets Management”For automated environments, store the CA key in a secrets manager:
| Tool | Command |
|---|---|
| HashiCorp Vault | vault kv put secret/mantis/ca key=@ca-key.pem |
| AWS Secrets Manager | aws secretsmanager create-secret --name mantis-ca-key --secret-binary fileb://ca-key.pem |
| Azure Key Vault | az keyvault secret set --vault-name mantis --name ca-key --file ca-key.pem |
Hardware Security Module (HSM)
Section titled “Hardware Security Module (HSM)”For the highest security, store the CA key in an HSM:
- AWS CloudHSM
- Azure Dedicated HSM
- On-premise PKCS#11 HSM
Verification After Restore
Section titled “Verification After Restore”After restoring certificates from backup, verify everything works:
# Verify CA certificateopenssl x509 -in /etc/mantis/certs/ca-cert.pem -noout -text | head -20
# Verify component certificates are signed by the CAopenssl verify -CAfile /etc/mantis/certs/ca-cert.pem /etc/mantis/certs/mandible-cert.pemopenssl verify -CAfile /etc/mantis/certs/ca-cert.pem /etc/mantis/certs/server-cert.pemopenssl verify -CAfile /etc/mantis/certs/ca-cert.pem /etc/mantis/certs/client-cert.pemopenssl verify -CAfile /etc/mantis/certs/ca-cert.pem /etc/mantis/certs/dispatch-cert.pem
# Check certificate expiry datesfor cert in /etc/mantis/certs/*-cert.pem; do echo "$cert: $(openssl x509 -in "$cert" -noout -enddate)"done
# Restart services and verify connectivity.# /health/grpc exposes the overall status (healthy/degraded/unhealthy) to any# caller; the breaker internals (circuit_state, failure_count, success_count)# are only returned to authenticated callers. Anonymous requests get an empty# circuit_state and zeroed counts, so pass a token to inspect the breaker.systemctl restart mantis-mandible mantis-thorax mantis-tarsuscurl -s -H "Authorization: Bearer $TOKEN" \ https://localhost:3000/api/v1/health/grpc | jqNext Steps
Section titled “Next Steps”- Key Rotation Runbook — Scheduled certificate rotation
- Database Backup — Back up the Mantis database
- Disaster Recovery — Full system recovery procedures
- Certificate Issues — Troubleshoot certificate problems
