configure ssl for MongoDB:
net:
port: 27017
bindIp: 127.0.0.1
ssl:
mode: requireSSL
PEMKeyFile: /etc/ssl/mongodb.pem
CAFile: /etc/ssl/ca.pem
restart:
service mongod restart
then:
mongo-- ssl-- host www.ericchoo.cn-- sslPEMKeyFile / etc/ssl/mongodb.pem-- sslCAFile / etc/ssl/ca.pem
error report:
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
at this time, I remove the ssl configuration from conf, restart mongod, and run mongo shell, and then I can connect again.
this may be my certificate. Is there a problem? (the AsiaInfo certificate downloaded by Tencent Cloud is not transferred by pem, with openssl) or my step is wrong.