SPIFFE/mTLS Authentication
SPIFFE (Secure Production Identity Framework for Everyone) provides a standardized way to issue and manage service identities using X.509 certificates. RunReveal supports SPIFFE-based mutual TLS (mTLS) authentication for ClickHouse connections, enabling secure service-to-service communication without passwords.
Why Use SPIFFE/mTLS?
- Enhanced Security: Certificates are more secure than static passwords and can be automatically rotated
- Zero Trust Architecture: Every connection is authenticated with cryptographic proof of identity
- Kubernetes Native: Works seamlessly with SPIFFE implementations like SPIRE in Kubernetes environments
- Automatic Rotation: Certificates can be rotated without service restarts
SPIFFE/mTLS is recommended for production BYOC deployments where ClickHouse runs in the same network as RunReveal services.
Supported Destinations
SPIFFE authentication works with both:
- Default ClickHouse - The global/shared ClickHouse cluster configured via environment
- Custom Destinations (BYODB) - Per-workspace ClickHouse instances configured in destination settings
For BYODB destinations, enable SPIFFE by setting useSPIFFE: true in the destination configuration.
Configuration
Enable SPIFFE authentication by setting the following configuration options:
Configuration Options
| Option | Description | Default |
|---|---|---|
defaultDestEnabled | Enable SPIFFE for the default/multi-tenant ClickHouse destination | false |
certPath | Path to the client certificate file | /etc/identity/tls.crt |
keyPath | Path to the client private key file | /etc/identity/tls.key |
caCertPath | Path to the CA certificate for server verification | (none) |
refreshInterval | How often to check for certificate updates | 10m |
When SPIFFE is enabled, the certificate Common Name (CN) or the X-ClickHouse-User header is used for ClickHouse authentication. Ensure your ClickHouse user configuration matches.
Certificate Requirements
Your SPIFFE certificates must meet these requirements:
- Format: PEM-encoded X.509 certificates
- Key Usage: Client authentication (
clientAuthextended key usage) - Common Name: Must match the ClickHouse username you want to authenticate as
- Validity: Certificate must be valid (not expired)
Example Certificate Structure
ClickHouse Server Configuration
Configure your ClickHouse server to accept certificate-based authentication:
Enable HTTPS
Add SSL configuration to your ClickHouse config.xml:
Create Certificate-Authenticated User
Add a user that authenticates via certificate CN in users.xml:
Verify Configuration
Test the connection using curl:
Certificate Rotation
RunReveal automatically watches for certificate changes and reloads them without requiring a restart. The refreshInterval setting controls how often the certificate files are checked for updates.
When certificates are rotated:
- Your SPIFFE provider (e.g., SPIRE) writes new certificates to the configured paths
- RunReveal detects the file change within the
refreshIntervalperiod - New connections use the updated certificates automatically
- Existing connections continue until they're recycled by the connection pool
Set refreshInterval to match your certificate rotation frequency. For short-lived certificates (common in SPIRE), use a shorter interval like 1m.
Kubernetes with SPIRE
If you're using SPIRE in Kubernetes, configure the SPIRE agent to project certificates to your RunReveal pods:
Troubleshooting
Connection refused on HTTPS port
- Verify ClickHouse is listening on the HTTPS port:
netstat -tlnp | grep 8443 - Check ClickHouse logs for SSL initialization errors
- Ensure the server certificate and key are readable by ClickHouse
Debug Logging
Enable debug logging to troubleshoot certificate issues:
Look for log messages containing "SPIFFE" or "watching SPIFFE certificates" to verify the certificate watcher is running.
Related Documentation
- Deployment Guide - Setting up RunReveal in your environment
- ClickHouse Configuration - ClickHouse SSL documentation
- SPIFFE Documentation - Learn more about SPIFFE