Skip to content

Instantly share code, notes, and snippets.

View hungio's full-sized avatar

Danh Hung hungio

View GitHub Profile
@hungio
hungio / mongodb-ssl.sh
Last active March 30, 2021 08:23 — forked from kevinadi/mongodb-ssl.sh
Script to create self-signed CA certificates, server certificates, and client certificates for testing MongoDB with SSL
#!/bin/sh
# For multi domain, add reqexts option when generate cer
# --reqexts SAN -config <(cat /etc/ssl/openssl.cnf <(printf "[SAN]\nsubjectAltName=DNS:example.com,DNS:www.example.com"))
# For wildcard domain, using '*' at first
# -subj "/C=AU/ST=NSW/L=Sydney/O=MongoDB/OU=root/CN=*.example.com/emailAddress=kevinadi@mongodb.com"
# Generate self signed root CA cert
openssl req -nodes -x509 -newkey rsa:2048 -keyout ca.key -out ca.crt -subj "/C=AU/ST=NSW/L=Sydney/O=MongoDB/OU=root/CN=`hostname -f`/emailAddress=kevinadi@mongodb.com" -days 365