File tree Expand file tree Collapse file tree 3 files changed +37
-1
lines changed Expand file tree Collapse file tree 3 files changed +37
-1
lines changed Original file line number Diff line number Diff line change 43
43
mongodb-datasource /
44
44
grafana-storage /
45
45
46
- mongo-docs /
46
+ mongo-docs /
47
+ certs /
Original file line number Diff line number Diff line change
1
+ # /bin/bash
2
+ # Generate keys and certs to test local MongoDB TLS connection
3
+
4
+ set -e
5
+
6
+ mkdir -p certs
7
+
8
+ # Generate a Certificate Authority (CA)
9
+ openssl genrsa -out certs/ca.key 4096
10
+ openssl req -x509 -new -nodes -key certs/ca.key -sha256 -days 365 -out certs/ca.pem -subj " /CN=localhost"
11
+
12
+
13
+ # Generate a Server Key and Certificate Signing Request (CSR)
14
+ # Passphrase is set to 123
15
+ openssl genrsa -out certs/mongodb.key -passout pass:123 4096
16
+ openssl req -new -key certs/mongodb.key -out certs/mongodb.csr -subj " /CN=localhost"
17
+
18
+ # Sign the Server Certificate with the CA
19
+ openssl x509 -req -extfile <( printf " subjectAltName=DNS:localhost" ) -in certs/mongodb.csr -CA certs/ca.pem -CAkey certs/ca.key -CAcreateserial -out certs/mongodb.crt -days 365 -sha256
20
+
21
+ # Combine Server Key and Certificate
22
+ cat certs/mongodb.key certs/mongodb.crt > certs/mongodb.pem
Original file line number Diff line number Diff line change
1
+ # /bin/bash
2
+ # Start MongoDB service with different configurations
3
+
4
+ # --tls
5
+ if [ " $1 " == " --tls" ]; then
6
+ echo " Starting MongoDB with TLS..."
7
+ docker run --rm --name mongodb-ds-mongo-tls -v ./mongod.conf:/etc/mongo/mongod.conf \
8
+ -v ./certs:/certs -p 27017:27017 -d mongo --config /etc/mongo/mongod.conf
9
+ # if no configuration is provided, start with default settings
10
+ else
11
+ echo " Starting MongoDB with default settings..."
12
+ docker run --rm --name mongodb-ds-mongo -d mongo
13
+ fi
You can’t perform that action at this time.
0 commit comments