Certificate Management
🔒 Automated Certificate Setup
Section titled “🔒 Automated Certificate Setup”One-Command Certificate Generation
Section titled “One-Command Certificate Generation”# Generate all certificates automaticallymake generate-docker-certs
What this creates:
- ✅ Certificate Authority (CA) - Your own trusted root
- ✅ Server certificates - For HTTPS endpoints
- ✅ Client certificates - For API authentication
- ✅ Database certificates - For encrypted connections
Certificate Structure
Section titled “Certificate Structure”📁 Certificate Directory
Section titled “📁 Certificate Directory”certs/├── ca/ # Certificate Authority│ ├── ca.crt # Root CA certificate│ └── ca.key # Root CA private key├── server/ # Server certificates│ ├── server.crt # Server certificate│ └── server.key # Server private key├── client/ # Client certificates│ ├── client.crt # Client certificate│ └── client.key # Client private key├── postgres/ # Database SSL│ ├── server.crt # PostgreSQL certificate│ └── server.key # PostgreSQL private key└── redis/ # Cache TLS ├── server.crt # Redis certificate └── server.key # Redis private key
How Certificates Work
Section titled “How Certificates Work”🔐 Security Flow
Section titled “🔐 Security Flow”1. Client → Presents client certificate2. Server → Validates against CA3. Server → Presents server certificate4. Client → Validates against CA5. Secure → Encrypted communication established
🏦 Bank-Grade Security
Section titled “🏦 Bank-Grade Security”- TLS 1.3+ - Latest encryption standards
- Mutual TLS (mTLS) - Both sides authenticate
- 2048-bit RSA - Strong encryption keys
- SHA-256 - Secure hashing algorithm
Using Certificates
Section titled “Using Certificates”🌐 API Requests with Certificates
Section titled “🌐 API Requests with Certificates”# Make authenticated API requestcurl -X POST https://localhost:8443/api/v1/verify \ --cert certs/client/client.crt \ --key certs/client/client.key \ -H "Content-Type: application/json" \ -d '{ "iban": "DE89370400440532013000", "name": "John Smith" }'
💻 JavaScript Integration
Section titled “💻 JavaScript Integration”// Node.js with certificatesconst fs = require('fs');const https = require('https');
const options = { cert: fs.readFileSync('certs/client/client.crt'), key: fs.readFileSync('certs/client/client.key'), ca: fs.readFileSync('certs/ca/ca.crt')};
const agent = new https.Agent(options);
// Use with fetch or axiosconst response = await fetch('https://localhost:8443/api/v1/verify', { method: 'POST', agent: agent, headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ iban, name })});
🐍 Python Integration
Section titled “🐍 Python Integration”import requests
# Use certificates with requestsresponse = requests.post( 'https://localhost:8443/api/v1/verify', cert=('certs/client/client.crt', 'certs/client/client.key'), verify='certs/ca/ca.crt', json={'iban': 'DE89370400440532013000', 'name': 'John Smith'})
Certificate Validation
Section titled “Certificate Validation”✅ Check Certificate Details
Section titled “✅ Check Certificate Details”# View certificate informationopenssl x509 -in certs/server/server.crt -text -noout
# Check certificate expirationopenssl x509 -in certs/server/server.crt -noout -dates
# Verify certificate chainopenssl verify -CAfile certs/ca/ca.crt certs/server/server.crt
🔍 Certificate Information
Section titled “🔍 Certificate Information”# Expected output for server certificate:Subject: CN=localhost, O=VoP Service, C=DEIssuer: CN=VoP Service CA, O=VoP Service, C=DEValidity: Not Before: 2024-01-01, Not After: 2026-01-01Subject Alternative Name: DNS:localhost, IP:127.0.0.1
Certificate Renewal
Section titled “Certificate Renewal”🔄 Automatic Renewal
Section titled “🔄 Automatic Renewal”# Regenerate expiring certificatesmake generate-docker-certs
# Restart services with new certificatesmake restart-ecp
⏰ Certificate Expiration Monitoring
Section titled “⏰ Certificate Expiration Monitoring”# Check when certificates expiremake check-cert-expiry
# Expected output:# CA Certificate: 3650 days remaining# Server Certificate: 730 days remaining# Client Certificate: 730 days remaining
📅 Renewal Schedule
Section titled “📅 Renewal Schedule”- Development: Certificates valid for 2 years
- Production: Recommend 90-day rotation
- CA Certificate: Valid for 10 years
Production Certificate Management
Section titled “Production Certificate Management”🏭 Production Setup
Section titled “🏭 Production Setup”# Generate production certificates with custom domainmake generate-production-certs DOMAIN=your-domain.com
# This creates certificates for:# - your-domain.com# - api.your-domain.com# - *.your-domain.com
🔐 Security Best Practices
Section titled “🔐 Security Best Practices”# Set secure permissionschmod 600 certs/*/private.keychmod 644 certs/*/certificate.crt
# Backup certificates securelytar -czf certificates-backup-$(date +%Y%m%d).tar.gz certs/gpg --encrypt --recipient admin@yourcompany.com certificates-backup-*.tar.gz
Troubleshooting
Section titled “Troubleshooting”🚫 Certificate Errors
Section titled “🚫 Certificate Errors”“Certificate verify failed”
# Regenerate all certificatesmake generate-docker-certsmake restart-ecp
“SSL handshake failed”
# Check certificate validityopenssl s_client -connect localhost:8443 -cert certs/client/client.crt -key certs/client/client.key
# Should show: Verify return code: 0 (ok)
“Permission denied”
# Fix certificate permissionssudo chown -R $USER:$USER certs/chmod -R 600 certs/*/private.keychmod -R 644 certs/*/certificate.crt
🔧 Common Fixes
Section titled “🔧 Common Fixes”# Clean and regenerate everythingmake clean-certsmake generate-docker-certs
# Test certificate setupmake test-certificates
# Verify service can startmake ecp-status
Integration with External Systems
Section titled “Integration with External Systems”🌐 Load Balancer Integration
Section titled “🌐 Load Balancer Integration”# Export certificates for load balancermake export-certs-for-lb
# Creates:# - lb-server.crt (for load balancer)# - lb-server.key (for load balancer)# - ca-bundle.crt (for client validation)
☁️ Cloud Integration
Section titled “☁️ Cloud Integration”# Export for AWS Certificate Managermake export-certs-aws
# Export for Azure Key Vaultmake export-certs-azure
# Export for Google Cloud Certificate Managermake export-certs-gcp