gpt4 book ai didi

mongodb - meteor 连接远程mongodb错误自签名证书

转载 作者:行者123 更新时间:2023-12-03 15:59:08 24 4
gpt4 key购买 nike

我想将我的 meteor 应用程序连接到scalegrid中的mongodb云。

MONGO_URL=mongodb://admin:PASSWORD@SG-Brain-77777.servers.mongodirector.com:27017/admin?ssl=true meteor run

但出现这样的错误:

W20200510-10:53:22.340(7)? (STDERR) MongoNetworkError: failed to connect to server [sg-brain-77777.servers.mongodirector.com:27017] on first connect [Error: self signed certificate
W20200510-10:53:22.340(7)? (STDERR) at TLSSocket.onConnectSecure (_tls_wrap.js:1473:34)
W20200510-10:53:22.340(7)? (STDERR) at TLSSocket.emit (events.js:311:20)
W20200510-10:53:22.340(7)? (STDERR) at TLSSocket.EventEmitter.emit (domain.js:482:12)
W20200510-10:53:22.340(7)? (STDERR) at TLSSocket._finishInit (_tls_wrap.js:916:8)
W20200510-10:53:22.340(7)? (STDERR) at TLSWrap.ssl.onhandshakedone (_tls_wrap.js:686:12) {
W20200510-10:53:22.340(7)? (STDERR) name: 'MongoNetworkError',
W20200510-10:53:22.341(7)? (STDERR) [Symbol(mongoErrorContextSymbol)]: {}
W20200510-10:53:22.341(7)? (STDERR) }]

添加后出现错误main.js 中导入 '../imports/api/posts';

---- 编辑自 meteor 论坛

我在scalegrid中有mongodb数据库集群,但我无法像这样连接到它:

MONGO_URL=mongodb://admin:password@SG-Brain-77777.servers.mongodirector.com:27017/admin?ssl=true meteor run

我尝试在终端中使用简单的 mongo 连接

mongo mongodb://admin:password@SG-Brain-77777.servers.mongodirector.com:27017/admin?ssl=true

但仍然无法连接并出现相同的错误:SSL 对等证书验证失败:自签名证书

我试着把它做成这样:

mongo mongodb://admin:password@SG-Brain-77777.servers.mongodirector.com:27017/admin?ssl=true --ssl --sslCAFile ./.crt

它有效!!!

现在的问题是,我无法像这样在MONGO_URL中添加--ssl --sslCAFile ./.crt,因为它会出错:

MONGO_URL=mongodb://admin:password@SG-Brain-77777.servers.mongodirector.com:27017/admin?ssl=true --ssl --sslCAFile ./.crt meteor run

如何将 ssl 证书添加到 mongo url?

<小时/>

我尝试过的新更新:

MONGO_URL=mongodb://admin:password@SG-Brain-77777.servers.mongodirector.com:27017/admin?ssl=true,ssl_ca_certs=./.crt meteor run

出现错误:

MongoNetworkError: failed to connect to server [sg-brain-77777.servers.mongodirector.com:27017] on first connect [MongoNetworkError: connection 0 to sg-brain-77777.servers.mongodirector.com:27017 closed

最佳答案

解决方案:

您需要specify the MongoDB SSL CA Certificate in Meteor settings .

分步指南:

  1. 登录 Scalegrid 并为您的 Meteor 应用选择集群。

  2. 滚动到底部,然后点击获取 SSL CA 证书 enter image description here

  3. 将文本复制到新文件private/scalegrid-cert.pem

NOTE: it's safe to commit private/scalegrid-cert.pem to your repo because it contains a public key. Bear in mind some .pem files include private keys and should never be added to a repo.

  • 将以下内容添加到您的 Meteor 设置环境变量
  •   "packages": {
    "mongo": {
    "options": {
    "tls": true,
    "tlsCAFileAsset": "scalegrid-cert.pem"
    }
    }
    }

    NOTE: it's "tlsCAFileAsset": "scalegrid-cert.pem"not "tlsCAFileAsset": "private/scalegrid-cert.pem". See the docs for why.

    关于mongodb - meteor 连接远程mongodb错误自签名证书,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61706982/

    24 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com