OpenLIT OpAMP Server - TLS Certificate Management
This document explains how to set up and manage TLS certificates for secure OpAMP communication between the OpenLIT server and OpAMP supervisors.
Overview
The OpenLIT OpAMP server uses TLS certificates to secure communication with OpAMP supervisors. This implementation provides:
- Self-signed CA for development and testing
- Production-ready certificate management with proper validation
- Environment-aware configuration (development vs production)
- Mutual TLS support for enhanced security
- Certificate validation and monitoring utilities
Quick Start
1. Generate Certificates
cd src/opamp-server/certs
./generate.sh
2. Configure Environment
For Development:
export OPAMP_ENVIRONMENT=development
export OPAMP_CERTS_DIR=/path/to/certs
For Production:
export OPAMP_ENVIRONMENT=production
export OPAMP_CERTS_DIR=/path/to/certs
export OPAMP_TLS_INSECURE_SKIP_VERIFY=false
3. Start the Server
cd src/opamp-server
./opamp-server
4. Configure Supervisors
For Development:
./setup-supervisor.sh --development
For Production:
./setup-supervisor.sh --production --server-url wss://your-server:4320/v1/opamp
Certificate Structure
certs/
├── cert/
│ └── ca.cert.pem # CA certificate (public)
├── private/
│ └── ca.key.pem # CA private key (keep secure!)
├── server/
│ ├── server.cert.pem # Server certificate
│ ├── server.key.pem # Server private key
│ └── server.csr # Server certificate signing request
├── client/
│ ├── client.cert.pem # Client certificate (optional)
│ ├── client.key.pem # Client private key (optional)
│ └── client.csr # Client certificate signing request
└── generate.sh # Certificate generation script
Environment Configuration
Environment Variables
| Variable | Default | Description |
|---|---|---|
OPAMP_ENVIRONMENT |
production |
Environment mode (development, production, testing) |
OPAMP_CERTS_DIR |
/app/opamp/certs |
Certificate directory path |
OPAMP_TLS_INSECURE_SKIP_VERIFY |
false |
Skip certificate verification (dev only) |
OPAMP_TLS_REQUIRE_CLIENT_CERT |
true |
Require client certificates for mutual TLS |
OPAMP_TLS_MIN_VERSION |
1.2 |
Minimum TLS version |
OPAMP_TLS_MAX_VERSION |
1.3 |
Maximum TLS version |
Environment Modes
Development Mode
insecure_skip_verify: trueby default- Client certificates not required
- Relaxed certificate validation
- Suitable for local development and testing
Production Mode (Default)
insecure_skip_verify: false(strict verification)- Client certificates required for mutual TLS authentication
- Full certificate chain validation
- Certificate expiry monitoring
- Secure cipher suites only
Testing Mode
- Similar to development mode
- Optimized for automated testing
- Flexible certificate validation
Certificate Generation
Basic Generation
cd certs/
./generate.sh
Advanced Options
# Clean existing certificates and regenerate
./generate.sh --clean
# Set custom certificate validity periods
CERT_VALIDITY_DAYS=7300 SERVER_CERT_DAYS=730 ./generate.sh
# Generate with custom configuration
CERT_VALIDITY_DAYS=3650 ./generate.sh
Certificate Properties
- Key Size: 4096-bit RSA keys for enhanced security
- Hash Algorithm: SHA-256
- CA Validity: 10 years (configurable)
- Server/Client Validity: 1 year (configurable)
- Extensions: Proper key usage and extended key usage
- Subject Alternative Names: Comprehensive SAN list for flexibility
Subject Alternative Names (SANs)
The server certificate includes SANs for various deployment scenarios:
localhost- Local development127.0.0.1,0.0.0.0- Local IP addresses172.17.0.1- Docker default bridgehost.docker.internal- Docker host access
For production, customize the SANs in server_ext.conf:
[alt_names]
DNS.1 = your-domain.com
DNS.2 = opamp.your-domain.com
IP.1 = 192.168.1.100
Supervisor Configuration
Development Setup
server:
endpoint: wss://localhost:4320/v1/opamp
tls:
insecure_skip_verify: true
Production Setup
server:
endpoint: wss://your-server:4320/v1/opamp
tls:
insecure_skip_verify: false
ca_file: /app/opamp/certs/cert/ca.cert.pem
# Required for mutual TLS (default in production):
cert_file: /app/opamp/certs/client/client.cert.pem
key_file: /app/opamp/certs/client/client.key.pem
Automated Setup
Use the provided setup script:
# Development configuration
./setup-supervisor.sh --development
# Production configuration
./setup-supervisor.sh --production \
--server-url wss://my-server:4320/v1/opamp \
--output-dir /etc/opamp
Security Best Practices
Certificate Management
- Secure Storage: Store private keys with restricted permissions (600)
- Regular Rotation: Rotate certificates before expiration
- CA Protection: Keep CA private key highly secure
- Distribution: Securely distribute CA certificates to clients
Production Deployment
- Use Real Domains: Configure proper DNS names in certificates
- Enable Mutual TLS: Use client certificates for authentication
- Monitor Expiry: Set up alerts for certificate expiration
- Secure Transport: Always use TLS in production
File Permissions
# Set proper permissions after certificate generation
chmod 600 private/*.pem client/*.key.pem server/*.key.pem
chmod 644 cert/*.pem client/*.cert.pem server/*.cert.pem
chmod 700 private/
Troubleshooting
Common Issues
"certificate signed by unknown authority"
Cause: Client doesn't trust the self-signed CA certificate.
Solutions:
- Development: Set
insecure_skip_verify: truein supervisor config - Production: Provide CA certificate path in supervisor config
- Verify: Ensure CA certificate is accessible and readable
"tls: certificate required" / "client didn't provide a certificate"
Cause: Server requires client certificates for mutual TLS, but client configuration is missing certificate files.
Solutions:
- Check client certificate files exist:
ls -la /app/opamp/certs/client/client.cert.pem ls -la /app/opamp/certs/client/client.key.pem - Regenerate certificates if missing:
cd /app/opamp/certs && ./generate.sh --clean - Update supervisor configuration:
server: tls: cert_file: /app/opamp/certs/client/client.cert.pem key_file: /app/opamp/certs/client/client.key.pem - Disable mutual TLS for development:
export OPAMP_TLS_REQUIRE_CLIENT_CERT=false
"certificate has expired"
Cause: Certificate validity period has passed.
Solutions:
- Regenerate certificates:
cd certs && ./generate.sh --clean - Check expiry:
openssl x509 -in cert/ca.cert.pem -noout -dates - Set longer validity:
CERT_VALIDITY_DAYS=7300 ./generate.sh
"certificate is valid for localhost, not your-server"
Cause: Certificate doesn't include the server's hostname/IP in SANs.
Solutions:
- Update
server_ext.confwith correct DNS names/IPs - Regenerate server certificate
- Use IP address or localhost for development
Connection refused or timeout
Cause: Network connectivity or server configuration issues.
Solutions:
- Verify server is running:
netstat -tlnp | grep 4320 - Check firewall rules for port 4320
- Verify WebSocket support in network infrastructure
"Can't load /root/.rnd into RNG"
Cause: OpenSSL trying to access a random number generator file that doesn't exist.
Solutions:
- Fixed automatically: This issue has been resolved in the current version
- Manual fix: Remove or comment out
RANDFILEinopenssl.conf - Verify fix: Run
./generate.shand check for the error
Validation Tools
Certificate Information
# View certificate details
openssl x509 -in cert/ca.cert.pem -noout -text
# Check certificate expiry
openssl x509 -in server/server.cert.pem -noout -dates
# Verify certificate chain
openssl verify -CAfile cert/ca.cert.pem server/server.cert.pem
Test TLS Connection
# Test TLS handshake
openssl s_client -connect localhost:4320 -CAfile cert/ca.cert.pem
# Test with client certificate
openssl s_client -connect localhost:4320 \
-CAfile cert/ca.cert.pem \
-cert client/client.cert.pem \
-key client/client.key.pem
Built-in Validation
# Run certificate validation (requires Go build)
cd src/opamp-server
OPAMP_CERTS_DIR=/path/to/certs go run -tags validation ./cmd/validate-certs
Advanced Configuration
Custom Certificate Authority
For production environments, you may want to use certificates from a trusted CA:
- Obtain certificates from your CA (Let's Encrypt, internal CA, etc.)
- Update paths in configuration to point to your certificates
- Ensure compatibility with OpAMP server certificate requirements
Mutual TLS (mTLS)
Enable mutual TLS for enhanced security:
Server configuration:
export OPAMP_TLS_REQUIRE_CLIENT_CERT=trueSupervisor configuration:
server: tls: cert_file: /path/to/client.cert.pem key_file: /path/to/client.key.pem
Certificate Rotation
Implement automated certificate rotation:
- Monitor expiry using the built-in validation tools
- Generate new certificates before expiration
- Update configurations and restart services
- Validate connectivity after rotation
Support
For issues related to certificate management:
- Check the troubleshooting section above
- Review server and supervisor logs
- Validate certificate properties and expiry
- Test network connectivity and TLS handshake
Files Reference
generate.sh- Certificate generation scriptsetup-supervisor.sh- Supervisor configuration helperopenssl.conf- OpenSSL CA configurationserver.conf- Server certificate configurationserver_ext.conf- Server certificate extensionsclient.conf- Client certificate configurationsupervisor.yaml- Development supervisor configurationsupervisor-production.yaml- Production supervisor template