-
Notifications
You must be signed in to change notification settings - Fork 1
guides_tls_setup
Complete guide to configuring TLS and mutual TLS for secure communication.
- 📋 Übersicht
- ✨ Features
- 🚀 Quick Start
- 📖 Certificate Generation
- 💡 Best Practices
- 🔧 Troubleshooting
- 📚 Weitere Ressourcen
- 📝 Changelog
ThemisDB supports both HTTP and HTTPS modes with optional mutual TLS (mTLS) for enhanced security. This guide covers certificate generation, configuration, and testing.
Stand: 22. Dezember 2025
Version: 1.3.0
Kategorie: ⚙️ Operations/Admin
- 🔒 TLS 1.3 Support - Modern protocol with perfect forward secrecy
- 🔐 Mutual TLS (mTLS) - Client certificate verification
- 🛡️ Strong Ciphers - ECDHE-RSA-AES256-GCM-SHA384 and more
- 📋 Security Headers - HSTS, X-Frame-Options, CSP
- ✅ Certificate Chain Validation - Full chain verification
ThemisDB supports both HTTP and HTTPS modes with optional mutual TLS (mTLS) for enhanced security. This guide covers certificate generation, configuration, and testing.
- TLS 1.3 Support: Modern, secure protocol with perfect forward secrecy
- TLS 1.2 Fallback: Configurable for compatibility with legacy clients
- Strong Cipher Suites: ECDHE-RSA-AES256-GCM-SHA384, ECDHE-RSA-AES128-GCM-SHA256, ChaCha20-Poly1305
- Disabled Weak Protocols: SSLv2, SSLv3, TLSv1.0, TLSv1.1 explicitly disabled
- Client Certificate Verification: Enforce client authentication with X.509 certificates
- Certificate Chain Validation: Verify certificates against trusted CA bundle
- Client Identity Logging: Extract and log client certificate DN for audit trails
- HSTS (Strict-Transport-Security): Forces HTTPS for 1 year with subdomain inclusion
- X-Frame-Options: Prevents clickjacking attacks (DENY)
- X-Content-Type-Options: Prevents MIME type sniffing (nosniff)
- Content-Security-Policy: Restricts content sources (default-src 'self')
For development and testing only, use the provided script to generate self-signed certificates:
# Generate certificates in default location (config/certs)
./scripts/generate_test_certs.sh
# Generate certificates in custom location
./scripts/generate_test_certs.sh /path/to/certsThis script generates:
-
CA certificate and key (
ca.crt,ca.key) - Root authority for signing -
Server certificate and key (
server.crt,server.key) - For HTTPS endpoint -
Client certificate and key (
client.crt,client.key) - For mTLS authentication -
Full chain files (
server-fullchain.pem,client-bundle.pem) - Combined PEM formats
For production environments, obtain certificates from a trusted Certificate Authority (CA):
- Internal CA (e.g., Active Directory Certificate Services, HashiCorp Vault)
- Public CA (e.g., Let's Encrypt, DigiCert, GlobalSign)
- Enterprise PKI (integrate with existing organizational PKI infrastructure)
# Install certbot
sudo apt-get install certbot
# Obtain certificate (HTTP-01 challenge)
sudo certbot certonly --standalone -d themisdb.example.com
# Certificates will be in /etc/letsencrypt/live/themisdb.example.com/
# - fullchain.pem (server certificate + intermediate CA)
# - privkey.pem (private key)ThemisDB TLS configuration is controlled via environment variables:
# Enable HTTPS
export THEMIS_TLS_ENABLED=1
# Server certificate (PEM format)
export THEMIS_TLS_CERT=/path/to/server.crt
# Server private key (PEM format)
export THEMIS_TLS_KEY=/path/to/server.key
# Minimum TLS version (TLSv1.2 or TLSv1.3, default: TLSv1.3)
export THEMIS_TLS_MIN_VERSION=TLSv1.3
# Optional: Custom cipher list (OpenSSL format)
# export THEMIS_TLS_CIPHER_LIST="ECDHE-RSA-AES256-GCM-SHA384:ECDHE-RSA-AES128-GCM-SHA256"# Enable HTTPS with mTLS
export THEMIS_TLS_ENABLED=1
export THEMIS_TLS_CERT=/path/to/server.crt
export THEMIS_TLS_KEY=/path/to/server.key
# CA certificate for client verification
export THEMIS_TLS_CA_CERT=/path/to/ca.crt
# Require client certificate (enforce mTLS)
export THEMIS_TLS_REQUIRE_CLIENT_CERT=1#include "server/http_server.h"
themis::server::HttpServer::Config config;
config.host = "0.0.0.0";
config.port = 8443; // Standard HTTPS port
// Enable TLS
config.enable_tls = true;
config.tls_cert_path = "/path/to/server.crt";
config.tls_key_path = "/path/to/server.key";
config.tls_min_version = "TLSv1.3";
// Enable mTLS
config.tls_ca_cert_path = "/path/to/ca.crt";
config.tls_require_client_cert = true;
auto server = std::make_unique<themis::server::HttpServer>(
config, storage, secondary_index, graph_index, vector_index, tx_manager
);# Health check with CA verification
curl --cacert config/certs/ca.crt https://localhost:8443/health
# Skip verification (development only)
curl -k https://localhost:8443/health
# Test with verbose output
curl -v --cacert config/certs/ca.crt https://localhost:8443/metrics# Authenticate with client certificate
curl --cacert config/certs/ca.crt \
--cert config/certs/client.crt \
--key config/certs/client.key \
https://localhost:8443/health
# Test authenticated API endpoint
curl --cacert config/certs/ca.crt \
--cert config/certs/client.crt \
--key config/certs/client.key \
-H "Authorization: Bearer YOUR_TOKEN" \
https://localhost:8443/api/entities/test-key# Inspect server certificate
openssl x509 -in config/certs/server.crt -text -noout
# Check certificate chain
openssl verify -CAfile config/certs/ca.crt config/certs/server.crt
# Test TLS handshake
openssl s_client -connect localhost:8443 -CAfile config/certs/ca.crt
# Test mTLS handshake with client cert
openssl s_client -connect localhost:8443 \
-CAfile config/certs/ca.crt \
-cert config/certs/client.crt \
-key config/certs/client.key-
Private Key Protection: Store private keys with restricted permissions (
chmod 600) - Certificate Rotation: Implement automated certificate renewal (e.g., Let's Encrypt auto-renewal)
- Certificate Revocation: Monitor CRL/OCSP for revoked certificates (future enhancement)
- Key Separation: Never reuse private keys across environments (dev/staging/prod)
Default strong ciphers (automatically configured):
-
ECDHE-RSA-AES256-GCM-SHA384- Perfect Forward Secrecy (PFS) with AES-256 -
ECDHE-RSA-AES128-GCM-SHA256- PFS with AES-128 (performance/security balance) -
ECDHE-RSA-CHACHA20-POLY1305- PFS with ChaCha20 (mobile/IoT devices)
Avoid weak ciphers (automatically disabled):
- RC4, MD5, 3DES, DES, EXPORT ciphers
- Anonymous DH (aDH), NULL encryption
- Recommended: TLS 1.3 only (modern clients, highest security)
- Compatible: TLS 1.2+ (legacy client support, still secure)
- Prohibited: TLS 1.1, TLS 1.0, SSLv3, SSLv2 (deprecated, known vulnerabilities)
Enable mutual TLS for:
- Service-to-Service Communication (microservices authentication)
- High-Security APIs (financial, healthcare, government sectors)
- Zero-Trust Networks (verify every client connection)
- Compliance Requirements (PCI-DSS, HIPAA, GDPR)
Cause: Certificate or key file path is incorrect.
Solution: Verify paths with ls -l $THEMIS_TLS_CERT and ensure files are readable.
Cause: Client cannot verify server certificate (CA not trusted).
Solution: Add --cacert with CA certificate or install CA in system trust store.
Cause: Client did not provide certificate in mTLS mode.
Solution: Ensure client uses --cert and --key flags, or disable mTLS requirement.
Cause: Client closed connection abruptly (normal during testing).
Solution: Non-critical, can be ignored in development.
# Enable OpenSSL debug logging
export SSLKEYLOGFILE=/tmp/sslkeys.log
curl --cacert config/certs/ca.crt https://localhost:8443/health
# Analyze TLS handshake with tcpdump
sudo tcpdump -i lo -w /tmp/tls.pcap port 8443
# Open /tmp/tls.pcap in Wireshark with SSLKEYLOGFILE for decryption
# Check server logs for TLS details
tail -f data/logs/themis.log | grep -i "tls\|ssl\|handshake"Planned TLS/PKI features:
- OCSP Stapling (RFC 6066) for certificate revocation checking
- Certificate Pinning for HSM/TSA outbound connections
- Automated Let's Encrypt integration with ACME protocol
- Hardware Security Module (HSM) integration for private key storage
- Certificate Transparency (CT) log monitoring
- TLS session resumption (session IDs, session tickets)
- RFC 8446: TLS 1.3
- Mozilla SSL Configuration Generator
- OWASP TLS Cheat Sheet
- Qualys SSL Labs Server Test
- NIST SP 800-52 Rev. 2: TLS Guidelines
For issues or questions:
- Security Issues: Report to service@themisdb.org (do not open public issues)
- General Help: GitHub Issues or Discussions
- Documentation: https://docs.themisdb.io/security/tls
- Architecture-ACCESS-MODEL-IMPLEMENTATION-SUMMARY
- Architecture-ADR-003-pg-dump-sql-parser
- Architecture-BASEENTITY-PRINCIPLE
- Architecture-CACHE-STORAGE-INTEGRATION
- Architecture-CMAKE-ARCHITECTURE
- Architecture-CMAKE-FLAGS-REFERENCE
- Architecture-CMAKE-MODULAR-ARCHITECTURE
- Architecture-CONCERNS-ARCHITECTURE-DIAGRAM
- Architecture-CONCERNS-IMPLEMENTATION-SUMMARY
- Architecture-CONTENT-MODEL
- Architecture-COPILOT-THEMISDB-GRAPH-RAG-BACKEND-ARCHITECTURE
- Architecture-CRYPTO-AND-KEYS
- Architecture-FEATURE-FLAGS-REFERENCE
- Architecture-GPU-ARCHITECTURE-REVIEW-TEMPLATE
- Architecture-HTTP-SHUTDOWN-HARDENING
- Architecture-MIGRATION-GUIDE-CONCERNS
- Architecture-MIGRATION-GUIDE-v13-v14
- Architecture-MODULARIZATION-GUIDE
- Architecture-MODULAR-ARCHITECTURE-ROADMAP
- Architecture-MODULE-ARCHITECTURE-INDEX
- Architecture-P1D01-ISSMPLUGIN-DESIGN-REVIEW
- Architecture-P1-D01-ISSMPLUGIN-DESIGN-REVIEW
- Architecture-P1-D08-MAMBA-GOVERNANCE-CONTRACT
- Architecture-P1-P2-IMPLEMENTATION-COMPLETION-INDEX
- Architecture-PHASE0-COMPLETION-ASSESSMENT
- Architecture-PHASE3-QUERYENGINE-DI-ARCHITECTURE
- Architecture-PHASE4-INDEX-MANAGER-DI
- Architecture-POSTGRESQL-WIRE-PROTOCOL
- Architecture-QUERYENGINE-IMPLEMENTATION-GUIDE
- Architecture-QUERY-SCHEDULING
- Architecture-RAFT-CONSENSUS-DESIGN
- Architecture-README
- Architecture-README-SSM-HYBRID-IMPLEMENTATION
- Architecture-REFACTORING-SUMMARY
- Architecture-RESOURCE-POOLING
- Architecture-SOURCE-DIRECTORY-GUIDE
- Architecture-THEMIS-CORE-GUIDE
- Architecture-UNIFIED-ACCESS-MODEL
- Architecture-WAL-GRPC-MTLS-CONFIGURATION
- Architecture-WIRE-PROTOCOL-RETRY
- Architecture-boltzmann-observability-draft
- Architecture-experimental-logarithmic-vector-storage
- Architecture-llm-wiki-mvp-adr
- Architecture-rewrite-engine-architecture
- Architecture-rope-api-architecture
- Architecture-ssm-gguf-mamba-status
- Architecture-ssm-hybrid-analysis
- Architecture-ssm-hybrid-rollout-plan
- Architecture-ssm-plugin-interface-design-review
- Architecture-transaction-coordinators
- Architecture-wiki-secondary-index
- Architecture-wire-protocol
- Governance-DISABLED-STUB-POLICY
- Governance-DOCS-PR-POLICY
- Governance-GA-PROMOTION-SIGN-OFF
- Governance-GITHUB-MILESTONES-SETUP
- Governance-MATURITY-CLAIM-VERIFICATION-CHECKLIST
- Governance-MATURITY-EVIDENCE-REGISTRY
- Governance-MERGE-GATE-BOT-CONFIG
- Governance-MERGE-GATE-STATUS-LIVE
- Governance-PHASE3-ENFORCEMENT-RUNBOOK
- Governance-PHASE-1-CLOSURE-REPORT
- Governance-PHASE-CLOSURE-POLICY
- Governance-PHASE-DEPENDENCY-GRAPH
- Governance-PLUGIN-SUBMODULE-ROLLBACK
- Governance-PRODUCTION-READY-2026-DELIVERY-PLAN
- Governance-PR-VERSION-TARGETING
- Governance-PR-VERSION-TARGETING-BACKFILL
- Governance-QUERY-MODULE-STATUS
- Governance-README
- Governance-RELEASE-PROMOTION-GATE-POLICY
- Governance-RELEASE-VALIDATION-CHECKLIST
- Governance-SECURITY-MODULE-5671-EVIDENCE-SUMMARY
- Governance-SHARDING-P6-RESIDUAL-RISK-ACCEPTANCE
- Governance-SOURCECODE-COMPLIANCE-GOVERNANCE
- Governance-UPDATES-DEVELOPMENT-STATUS-SIGN-OFF
- Governance-WAVE-C-IMPLEMENTATION-COMPLETE
- Module-acceleration-Roadmap
- Module-access-model-Roadmap
- Module-ai-Roadmap
- Module-analytics-Roadmap
- Module-api-Roadmap
- Module-aql-Roadmap
- Module-auth-Roadmap
- Module-base-Roadmap
- Module-cache-Roadmap
- Module-cdc-Roadmap
- Module-chaos-Roadmap
- Module-chimera-Roadmap
- Module-config-Roadmap
- Module-content-Roadmap
- Module-core-Roadmap
- Module-distributed-knowledge-Roadmap
- Module-distributed-tensor-Roadmap
- Module-document-Roadmap
- Module-ethics-ai-Roadmap
- Module-evaluation-Roadmap
- Module-execution-Roadmap
- Module-exporters-Roadmap
- Module-failover-Roadmap
- Module-geo-Roadmap
- Module-governance-Roadmap
- Module-gpu-Roadmap
- Module-graph-Roadmap
- Module-image-analysis-Roadmap
- Module-importers-Roadmap
- Module-index-Roadmap
- Module-ingestion-Roadmap
- Module-llama-cpp-Roadmap
- Module-llm-Roadmap
- Module-llm-streaming-Roadmap
- Module-llm-wiki-Roadmap
- Module-maintenance-Roadmap
- Module-metadata-Roadmap
- Module-network-Roadmap
- Module-observability-Roadmap
- Module-onnx-clip-Roadmap
- Module-performance-Roadmap
- Module-plugins-Roadmap
- Module-process-Roadmap
- Module-projects-Roadmap
- Module-prompt-engineering-Roadmap
- Module-query-Roadmap
- Module-rag-Roadmap
- Module-replication-Roadmap
- Module-retrieval-Roadmap
- Module-rpc-grpc-Roadmap
- Module-scheduler-Roadmap
- Module-scraper-Roadmap
- Module-search-Roadmap
- Module-security-Roadmap
- Module-server-Roadmap
- Module-sharding-Roadmap
- Module-stable-diffusion-Roadmap
- Module-storage-Roadmap
- Module-temporal-Roadmap
- Module-tensor-Roadmap
- Module-themis-Roadmap
- Module-timeseries-Roadmap
- Module-toolbox-Roadmap
- Module-training-Roadmap
- Module-transaction-Roadmap
- Module-updates-Roadmap
- Module-user-storage-encrypted-Roadmap
- Module-utils-Roadmap
- Module-vector-search-Roadmap
- Module-voice-Roadmap
- Module-whisper-Roadmap