[英]MongoDB - SSL connection issues
作業系統版本-Ubuntu 12.04
MongoDB版本-3.2.5
貓鼬版本-4.10.8
生成SSL證書的步驟:
1. openssl req -newkey rsa:2048 -new -x509 -days 3650 -nodes -out mongodb-cert.crt -keyout mongodb-cert.key
2. cat mongodb-cert.key mongodb-cert.crt> mongodb.pem
啟動mongo服務器
mongo.conf
net:
port: 10023
bindIp: 10.x.x.x
ssl:
mode: allowSSL
PEMKeyFile: /etc/ssl/mongodb.pem
CAFile: /etc/ssl/mongodb-cert.crt
當我通過mongo客戶端連接時,此方法工作正常。
mongo --ssl-主機10.xxx-端口10023 --sslCAFile mongodb-cert.crt --sslPEMKeyFile mongodb.pem
但是它會導致貓鼬錯誤
var mongoose = require('mongoose');
var fs = require('fs');
var ca = fs.readFileSync("./mongodb-cert.crt");
var key = fs.readFileSync("./mongodb.pem");
var cert = fs.readFileSync("./mongodb-cert.crt");
mongoose.connect('mongodb://10.x.x.x:10023' + '/' + 'DBName' + '?ssl=true',
{
server: {
sslValidate: true,
sslCa: ca,
sslKey: key,
sslCert: cert
}
}
);
{名稱:'MongoError',消息:'自簽名證書'}
我猜您已經使用了https://docs.mongodb.com/manual/tutorial/configure-x509-client-authentication中的過程-我的最佳猜測是,在使用自簽名證書時,您不應該指定sslCA
參數。
sslCA
當你指的是發行中規定的證書認證機構,才應使用sslCert
。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.