首页 > 解决方案 > 带有自签名证书的 Mongo URI

问题描述

我试图让 Mongo URI 连接使用自签名证书。

命令行工作得很好,所以以下连接:

mongo mongodb://Qlik:Password1@mongobox.test:27017 --ssl --sslAllowInvalidCertificates

但是,根据文档,没有sslAllowInvalidCertificates=trueURI 连接选项,也没有任何方法可以提供证书(这在我的堆栈中无论如何都是一个问题)

URI 等价物:

mongo "mongodb://Qlik:Password1@mongobox.test:27017/?ssl=true&sslAllowInvalidCertificates=true"

结果是:

2019-10-17T07:19:00.490+0000 E QUERY    [js] Error: couldn't connect to server mongobox.test:27017, connection attempt failed: SSLHandshakeFailed: SSL peer certificate validation failed: unable to get local issuer certificate :
connect@src/mongo/shell/mongo.js:344:17
@(connect):2:6
exception: connect failed

如何让 URI 连接与自签名证书一起使用?

标签: mongodbssl

解决方案


mongo --host example.test \
      --ssl \
      --tlsAllowInvalidCertificates \
      --username myUsername

推荐阅读