Nic*_*rel 5 ssl openssl mongodb ubuntu-16.04
我在 Ubuntu 16.04.5 LTS 服务器上设置了一个具有 SSL 安全性的 mongoDB 数据库,并且已经使用它几个月了。为了在 mongo 上设置 SSL,我遵循了 Medium.com 上 Rajan Maharjan 的教程(链接)。短暂未使用后回到我的服务器,我收到以下错误消息:
SSL peer certificate validation failed: certificate has expired
查看mongo日志,发现:
[PeriodicTaskRunner] Server certificate is now invalid. It expired on 2018-11-10T08:10:11.000Z
因此,我按照与第一次创建证书时相同的步骤,使用 rootCA.key 文件重新生成并重新签署了所有证书。我用以下命令重新启动了 mongod:
service mongod restart
现在我有“自签名证书”错误:
MongoDB shell version v4.0.2
connecting to: mongodb://IP:port/
2018-11-21T13:11:10.584+0000 E NETWORK [js] SSL peer certificate
validation failed: self signed certificate
2018-11-21T13:11:10.584+0000 E QUERY [js] Error:
couldn't connect to server IP:port, connection attempt failed:
SSLHandshakeFailed: SSL peer certificate validation failed: self signed certificate :
connect@src/mongo/shell/mongo.js:257:13
@(connect):1:6
exception: connect failed
Run Code Online (Sandbox Code Playgroud)
我的连接字符串如下:
mongo --ssl --sslCAFile /PATH/TO/rootCA.pem --sslPEMKeyFile /PATH/TO/mongodb.pem --host IP:port
我没有找到任何有关 mongoDB 重新签名证书的资源。任何帮助将非常感激。
/etc/mongod.conf :
# mongod.conf
# for documentation of all options, see:
# http://docs.mongodb.org/manual/reference/configuration-options/
# Where and how to store data.
storage:
dbPath: /var/lib/mongodb
journal:
enabled: true
# engine:
# mmapv1:
# wiredTiger:
# where to write logging data.
systemLog:
destination: file
logAppend: true
path: /var/log/mongodb/mongod.log
# network interfaces
net:
port: PORT
bindIp: IP
ssl:
mode: requireSSL
PEMKeyFile: /etc/ssl/mongodb.pem
CAFile: /etc/ssl/rootCA.pem
# how the process runs
processManagement:
timeZoneInfo: /usr/share/zoneinfo
#security:
security:
authorization: "enabled"
#operationProfiling:
#replication:
#sharding:
## Enterprise-Only Options:
#auditLog:
#snmp:
Run Code Online (Sandbox Code Playgroud)
我已经按照以下步骤设法让它再次工作(由于某种原因,以前不起作用):
mongodb.*文件/etc/ssl/openssl genrsa -out mongodb.key 2048
openssl req -new -key mongodb.key -out mongodb.csr
Run Code Online (Sandbox Code Playgroud)
Common Name (eg, YOUR name) []openssl genrsa -out mongodb.key 2048
openssl req -new -key mongodb.key -out mongodb.csr
Run Code Online (Sandbox Code Playgroud)
mongo --ssl --sslCAFile /PATH/TO/rootCA.pem --sslPEMKeyFile /PATH/TO/mongodb.pem --host IP:PORT
Run Code Online (Sandbox Code Playgroud)
感谢@AniketMaithani 试图帮助我解决这个问题。