配置 MongoDB 的ssl :
net:
port: 27017
bindIp: 127.0.0.1
ssl:
mode: requireSSL
PEMKeyFile: /etc/ssl/mongodb.pem
CAFile: /etc/ssl/ca.pem
重启:
service mongod restart
然后:
mongo --ssl --host www.ericchoo.cn --sslPEMKeyFile /etc/ssl/mongodb.pem --sslCAFile /etc/ssl/ca.pem
报错:
2018-05-18T02:09:08.977+0800 W NETWORK [thread1] Failed to connect to 139.199.188.225:27017, in(checking socket for error after poll), reason: Connection refused
2018-05-18T02:09:08.978+0800 E QUERY [thread1] Error: couldn't connect to server www.ericchoo.cn:27017, connection attempt failed :
connect@src/mongo/shell/mongo.js:251:13
@(connect):1:6
exception: connect failed
这个时候我去掉conf里的ssl配置,再重启mongod,再运行mongo shell就又可以连接了。
这里可能是我的证书有问题吗?(腾讯云下载的亚信证书,没有pem,用openssl转的)还是我的步骤是错的。