mongodb - Could not connect to MongoDB on the provided host and port with SSL/TLS encryption
问题描述
I'm follow the tutorial of MongoDB and I want to encrypt network traffic with certificates self-signed SSL/TLS in local. Once done this (I used OpenSSL), I start mongod in my cmd with the follow syntax:
mongod --sslMode requireSSL --sslPEMKeyFile test-server1.pem --sslCAFile test-ca.pem
The files .pem are signed follow the tutorials https://docs.mongodb.com/manual/appendix/security/ so I suppose that it's fine.
The instance is initiated and shows the follow message:
waiting for connections on port 27017 ssl
I start now the mongo shell with:
mongo --ssl --host localhost --sslPEMKeyFile test-client.pem --sslCAFile test-ca.pem
Then, this is the problem. The mongo shell terminal shows
....
Error: couldn't connect to server localhost:27017, connection attempt failed: HostUnreachable: Connection closed by peer
...
And the instance shows
....
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)
....
The connection is open and immediately close. I have tried all. I think that the problem could be the files .cnf that are used for signed the certificates, but I dont know.
Thanks for help
解决方案
推荐阅读
- python - 将 list = {"xy", "wz", "ab"} 转换为 dict={x:y. w:z,a:b}
- php - wp_mail 退订链接
- java - 从 React 连接到 Java 服务器
- visual-studio - 如何使用 PowerShell 监控 VSTS 代理的可用性?
- malware - 在公司的笔记本电脑上感染了强大的病毒。现在怎么办?
- mysql - 如何从主机访问hadoop VM中的mysql
- node.js - HTTPS 请求在 Node.js 中不起作用(代码 400)
- kubernetes - GKE上的可附加flexVolume不起作用
- shell - 生成哈希以匹配用户密码
- jquery - 为什么 jquery .remove 在我的情况下不起作用