无法使用SSL / TLS加密连接到提供的主机和端口上的MongoDB

时间:2019-06-12 10:06:48

标签: mongodb ssl encryption ssl-certificate

我正在遵循MongoDB的教程,我想在本地使用证书自签名SSL / TLS加密网络流量。完成此操作后(我使用了OpenSSL),我使用以下语法在cmd中启动mongod:

mongod --sslMode requireSSL --sslPEMKeyFile test-server1.pem --sslCAFile test-ca.pem

.pem文件已按照教程https://docs.mongodb.com/manual/appendix/security/签名,因此我认为这很好。

实例已启动,并显示以下消息:

waiting for connections on port 27017 ssl

我现在从以下内容开始mongo shell:

mongo --ssl --host localhost --sslPEMKeyFile test-client.pem --sslCAFile test-ca.pem

然后,这就是问题所在。 mongo shell终端显示

....
Error: couldn't connect to server localhost:27017, connection attempt failed: HostUnreachable: Connection closed by peer
...

实例显示

....
2019-06-12T11:52:39.819+0200 I NETWORK [initandlisten] waiting for connections on port 27017 ssl
2019-06-12T11:54:25.642+0200 I NETWORK [listener] connection accepted from 127.0.0.1:51005 #1 (1 connection now open)
2019-06-12T11:54:26.560+0200 I NETWORK [conn1] end connection 127.0.0.1:51005 (0 connections now open)
....

连接打开并立即关闭。我已经尝试了所有。 我认为问题可能出在用于对证书签名的.cnf文件中,但我不知道。

感谢帮助

0 个答案:

没有答案