TLS Certificates and Secure Communication
How to generate TLS certificates for MongoDB server and client communication.
Prerequisites
1. Create a Certificate Authority (CA)
mkdir -p /tmp/mongo_tls
cd /tmp/mongo_tls
# Generate CA key
openssl genrsa -out ca.key.pem 4096
# Generate CA certificate
openssl req -x509 -new -nodes -key ca.key.pem -sha256 -days 3650 -out ca.cert.pem -subj "/C=CH/L=Zurich/O=MongoCA/CN=mongodb.local.ca"2. Generate a Server Certificate (for TLS communication)
3. Generate a Client Certificate (for TLS communication)
4. Combine PEM Files
5. Change MongoDB configuration
Automated Script Example
Last updated