TLS encryption database
To ensure that communication from the APP server to the database is encrypted, the following steps must be taken:
[req] default_bits = 4096 default_md = sha256 distinguished_name = req_dn req_extensions = v3_req [v3_req] subjectKeyIdentifier = hash basicConstraints = CA:FALSE keyUsage = critical, digitalSignature, keyEncipherment extendedKeyUsage = serverAuth, clientAuth subjectAltName = @alt_names [alt_names] DNS.1 = <SERVER_NAME> IP.1 = <SERVER-IP> [req_dn] countryName = DE organizationName = Enginsight commonName = <DOMAIN_NAME>if [ ! -f ./passwd ] then echo $(openssl rand -base64 16) > ./passwd fi passwd=$(cat ./passwd) openssl genrsa -des3 -out mongodbCA.key -passout pass:$(echo ${passwd}) 4096 openssl req -x509 -new -nodes -key mongodbCA.key -sha256 -days 3650 -subj "/C=DE/ST=CA/O=Enginsight/CN=enginsight.com" -passin pass:$(echo ${passwd}) -out mongodbCA.crt openssl genrsa -out mongodb.key -passout pass:$(echo ${passwd}) 2048 openssl req -new -sha256 -key mongodb.key -out mongodb.csr -config csr.cnf -subj "/C=DE/O=Enginsight/CN=enginsight.com" openssl x509 -sha256 -req -days 3650 -passin pass:$(echo ${passwd}) -in mongodb.csr -CA mongodbCA.crt -CAkey mongodbCA.key -CAcreateserial -out mongodb.crt -extfile csr.cnf -extensions v3_req cat mongodb.key mongodb.crt > mongodb.pemsudo nano etc/mongod.conf net: port: 27017 bindIp: 0.0.0.0 tls: mode: requireTLS certificateKeyFile: /etc/enginsight/ssl/mongodb.pem CAFile: /etc/enginsight/ssl/mongodbCA.crtsudo service mongodb restartmongosh --tls --host <DB-HOST:PORT> --tlsCAFile /etc/enginsight/ssl/mongodbCA.crt --tlsCertificateKeyFile /etc/enginsight/ssl/mongodb.pemvolumes: - "./conf/ssl/:/etc/enginsight/ssl/"
Last updated
Was this helpful?