Home
About
Blog
Products
Forum
Support
Contact
Sunbelt Computer Software
PL/B Language Development and Support
Home
About
Blog
Products
Forum
Support
Contact
MongoDB/MongoDB_SSL_TSL_Configuration.sql at master · unidev39/MongoDB · GitHub
Skip to content
Navigation Menu
Sign in
Appearance settings
Platform
AI CODE CREATION
GitHub Copilot
Write better code with AI
GitHub Copilot app
Direct agents from issue to merge
MCP Registry
Integrate external tools
DEVELOPER WORKFLOWS
Actions
Automate any workflow
Codespaces
Instant dev environments
Issues
Plan and track work
Code Review
Manage code changes
Code Quality
Enforce quality at merge
APPLICATION SECURITY
GitHub Advanced Security
Find and fix vulnerabilities
Code security
Secure your code as you build
Secret protection
Stop leaks before they start
EXPLORE
Why GitHub
Documentation
Blog
Changelog
Marketplace
View all features
Solutions
BY COMPANY SIZE
Enterprises
Small and medium teams
Startups
Nonprofits
BY USE CASE
App Modernization
DevSecOps
DevOps
CI/CD
View all use cases
BY INDUSTRY
Healthcare
Financial services
Manufacturing
Government
See all industries
View all solutions
Resources
EXPLORE BY TOPIC
AI
Software Development
DevOps
Security
View all topics
EXPLORE BY TYPE
Customer stories
Events & webinars
Ebooks & reports
Business insights
GitHub Skills
SUPPORT & SERVICES
Documentation
Customer support
Community forum
Trust center
Partners
View all resources
Open Source
COMMUNITY
GitHub Sponsors
Fund open source developers
PROGRAMS
Security Lab
Maintainer Community
GitHub Stars
Archive Program
REPOSITORIES
Topics
Trending
Collections
Enterprise
ENTERPRISE SOLUTIONS
Enterprise platform
AI-powered developer platform
AVAILABLE ADD-ONS
GitHub Advanced Security
Enterprise-grade security features
Copilot for Business
Enterprise-grade AI features
Premium Support
Enterprise-grade 24/7 support
Pricing
Search
/
Sign in
Sign up
Appearance settings
You signed in with another tab or window.
Reload
to refresh your session.
You signed out in another tab or window.
Reload
to refresh your session.
You switched accounts on another tab or window.
Reload
to refresh your session.
Dismiss alert
{{ message }}
unidev39
MongoDB
Repository navigation
Code
Issues
Pull requests
Actions
Projects
Security and quality
Insights
More
items
Files
Expand file tree
master
Breadcrumbs
MongoDB
/
MongoDB_SSL_TSL_Configuration.sql
Copy path
Blame
More file actions
Blame
More file actions
Latest commit
History
History
History
147 lines (139 loc) · 5.99 KB
master
Breadcrumbs
MongoDB
/
MongoDB_SSL_TSL_Configuration.sql
Copy path
Top
File metadata and controls
Code
Blame
147 lines (139 loc) · 5.99 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
OS Level add your VM IP with certification name
C:\Windows\System32\drivers\etc\hosts
/*
192.168.159.130 localhost_ssl
*/
[root@localhost ~]
#
vi /etc/hosts
/*
192.168.159.130 localhost_ssl
*/
[root@localhost
/
]
#
mkdir -p /etc/ssl/mongossl
[root@localhost
/
]
#
cd /etc/ssl/mongossl
[root@localhost mongossl]
#
ls
[root@localhost mongossl]
#
openssl genrsa -des3 -out server.key 2048
/*
Generating RSA private key, 2048 bit long modulus
...................................+++
...............................................................+++
e is 65537 (0x10001)
Enter pass phrase for server.key:
Verifying - Enter pass phrase for server.key:
*/
[root@localhost mongossl]
#
ls
/*
server.key
*/
[root@localhost mongossl]
#
openssl rsa -in server.key -out server.key
/*
Enter pass phrase for server.key:
writing RSA key
*/
[root@localhost mongossl]
#
ls
/*
server.key
*/
[root@localhost mongossl]
#
openssl req -sha256 -new -key server.key -out server.csr -subj "/CN=localhost_ssl"
[root@localhost mongossl]
#
openssl x509 -req -sha256 -days 365 -in server.csr -signkey server.key -out server.crt
/*
Signature ok
subject=/CN=localhost_ssl
Getting Private key
*/
[root@localhost mongossl]
#
ls
/*
server.crt server.csr server.key
*/
[root@localhost mongossl]
#
cat server.crt server.key > cert.pem
[root@localhost mongossl]
#
ls
/*
cert.pem server.crt server.csr server.key
*/
[root@localhost mongossl]
#
openssl genrsa -out mongodb.key 2048
/*
Generating RSA private key, 2048 bit long modulus
.......................................................................................................................................................................+++
...................+++
e is 65537 (0x10001)
*/
[root@localhost mongossl]
#
openssl req -new -key mongodb.key -out mongodb.csr
/*
You are about to be asked to enter information that will be incorporated
into your certificate request.
What you are about to enter is what is called a Distinguished Name or a DN.
There are quite a few fields but you can leave some blank
For some fields there will be a default value,
If you enter '.', the field will be left blank.
-----
Country Name (2 letter code) [XX]:
State or Province Name (full name) []:
Locality Name (eg, city) [Default City]:
Organization Name (eg, company) [Default Company Ltd]:
Organizational Unit Name (eg, section) []:
Common Name (eg, your name or your server's hostname) []:localhost_ssl
Email Address []:
Please enter the following 'extra' attributes
to be sent with your certificate request
A challenge password []:
An optional company name []:
*/
[root@localhost mongossl]
#
ls
/*
cert.pem mongodb.csr mongodb.key server.crt server.csr server.key
*/
[root@localhost mongossl]
#
openssl x509 -req -in mongodb.csr -CA cert.pem -CAkey server.key -CAcreateserial -out mongodb.crt -days 500 -sha256
/*
Signature ok
subject=/C=XX/L=Default City/O=Default Company Ltd/CN=localhost_ssl
Getting CA Private Key
*/
[root@localhost mongossl]
#
ls
/*
cert.pem mongodb.crt mongodb.key server.csr
cert.srl mongodb.csr server.crt server.key
*/
[root@localhost mongossl]
#
cat mongodb.key mongodb.crt > mongodb.pem
[root@localhost mongossl]
#
systemctl stop mongod
[root@localhost mongossl]
#
systemctl status mongod
[root@localhost mongossl]
#
vi /etc/mongod.conf
/*
net:
port: 27017
bindIp: localhost_ssl
ssl:
mode: requireSSL
PEMKeyFile: /etc/ssl/mongossl/mongodb.pem
PEMKeyPassword: abc123
CAFile: /etc/ssl/mongossl/cert.pem
allowInvalidCertificates: true
allowInvalidHostnames: true
*/
[root@localhost mongossl]
#
systemctl start mongod
[root@localhost mongossl]
#
systemctl status mongod
--
Disable_Authentication_on_MongoDB
[root@localhost ~]
#
mongo --ssl --sslCAFile /etc/ssl/mongossl/cert.pem --sslPEMKeyFile /etc/ssl/mongossl/mongodb.pem --host localhost_ssl
--
Enable_Authentication_on_MongoDB with admin user
[root@localhost ~]
#
mongo --ssl --sslCAFile /etc/ssl/mongossl/cert.pem --sslPEMKeyFile /etc/ssl/mongossl/mongodb.pem --host localhost_ssl --port 27017 -u admin -p Admin@P@55w0rd --authenticationDatabase admin
--
Enable_Authentication_on_MongoDB with chatbox user
[root@localhost ~]
#
mongo --ssl --sslCAFile /etc/ssl/mongossl/cert.pem --sslPEMKeyFile /etc/ssl/mongossl/mongodb.pem --host localhost_ssl --port 27017 -u chatbox -p Ch@tB0x@P@55w0rd --authenticationDatabase chatbox
--
Backup
--
FullBackup
[root@localhost ~]
#
mongodump --ssl --sslCAFile /etc/ssl/mongossl/cert.pem --sslPEMKeyFile /etc/ssl/mongossl/mongodb.pem --host localhost_ssl --port 27017 -u admin -p Admin@P@55w0rd --authenticationDatabase admin --out /home/BackUpMongoDB/MongoFullBackup/dump/
--
ParticularBackup
[root@localhost ~]
#
mongodump --ssl --sslCAFile /etc/ssl/mongossl/cert.pem --sslPEMKeyFile /etc/ssl/mongossl/mongodb.pem --host localhost_ssl --port 27017 -u admin -p Admin@P@55w0rd --authenticationDatabase admin -d chatbox --out /home/BackUpMongoDB/MongoFullBackup/dump/
--
Restore
--
FullBackupRestore
[root@localhost ~]
#
mongorestore --ssl --sslCAFile /etc/ssl/mongossl/cert.pem --sslPEMKeyFile /etc/ssl/mongossl/mongodb.pem --host localhost_ssl:27017 -u admin -p Admin@P@55w0rd --authenticationDatabase admin /home/BackUpMongoDB/MongoFullBackup/dump/
--
ParticularBackupRestore
[root@localhost ~]
#
mongorestore --ssl --sslCAFile /etc/ssl/mongossl/cert.pem --sslPEMKeyFile /etc/ssl/mongossl/mongodb.pem --host localhost_ssl:27017 -u admin -p Admin@P@55w0rd --authenticationDatabase admin -d chatbox /home/BackUpMongoDB/MongoFullBackup/dump/chatbox
--
To Connect Mongodb using Compass
Hostname : localhost_ssl
Port :
27017
Authentication : Username
/
Password
Username : chatbox
Password : Ch@tB0x@P@55w0rd
Authentication Database : chatbox
Read Preference : Primary
SSL : Server
and
Client Validation
Certificate Authority : D:\mongossl\
server
.
crt
Client Certificate : D:\mongossl\
mongodb
.
crt
Client Private Key : D:\mongossl\
mongodb
.
key
You can’t perform that action at this time.