如何解决 MongoDB 中的 SSLHandshakeFailed 问题?

How can I resolve the issue for the SSLHandshakeFailed in MongoDB?

我对 MongoDB 很陌生。事实上,我是 MEAN Stack 的新手。我已经在 Mac 上成功安装了 MongoDB 服务器。在我 运行 以下命令之后:

mongod

服务器在端口 27017 上启动。我尝试通过在 chrome window:

上输入本地主机 URL 来访问服务器

http://127.0.0.1:27017/

我在服务器 运行ning 的终端 window 中收到以下错误:

SSLHandshakeFailed: SSL handshake received but server is started without SSL support.

为了解决这个问题,我用谷歌搜索了这个错误,并尝试了一些来自 this and this link 的建议:

openssl genrsa -des3 -out rootSSL.key 2048 这将创建一个 .key 文件。那么,

openssl req -x509 -new -nodes -key rootSSL.key -sha256 -days 1024 -out rootSSL.pem 这将创建一个 .pem 文件。

我什至在 Keychain Access 中的 System 中添加了 .pem 文件。

一些 link 建议我应该创建一个 server.cnf 文件,一些建议我应该创建一个域证书。

有人在SO的问题中也建议从Postman入手,但也不行。

任何人都可以帮助我找出这个错误,因为所有其他建议都非常混乱,而且所有这些建议似乎都在拐弯抹角。

如果您遇到此错误:

SSLHandshakeFailed: SSL handshake received but server is started without SSL support.

...您可能正在访问 https://127.0.0.1:27017/ 而不是 http://127.0.0.1:27017/。检查你的拼写。

此外,HTTP 接口不适用于最近的 MongoDB 版本。 The documentation 说:

Changed in version 3.6: MongoDB 3.6 removes the deprecated HTTP interface and REST API to MongoDB.

当我在 MongoDB 服务器上尝试此操作时,我得到:

% curl http://localhost:27017
It looks like you are trying to access MongoDB over HTTP on the native driver port.

因此,除了验证服务器已启动之外,通过网络浏览器访问它没有用。