У меня есть мон go кластер реплик с проверкой сервера ssl. Как я могу подключиться к этому с mon goose?
const key = fs.readFileSync(<Path to file>);
mongoose.connect(dbConectionString, {
sslCA: key,
useNewUrlParser: true,
useUnifiedTopology: true,
useCreateIndex: true,
}).then((x) => {
console.log('connected');
}).catch((err) => {
console.log(err);
});
Файл не имеет окончания файла и выглядит так:
-----BEGIN CERTIFICATE-----
MrPXxLy9NPj8isOutrLD29IY2A0V4RlcIxS0L7sVOy0zD6pmzMMQMD/5ifuIX6bq
[16 more rows]
VF1talRQZJjwryXlXboCG4156MKpL201L2WWjk0rvPUZ
-----END CERTIFICATE-----
Это работает (MongoDB Compass)
Сообщение об ошибке при этой настройке
connection error: MongooseError [MongooseServerSelectionError]: connection <monitor> to <server-ip>:<server-port> closed
at new MongooseServerSelectionError (D:\git_repos\WirVsVirus\Coronahelfer-Hackathon\node_modules\mongoose\lib\error\serverSelection.js:22:11)
at NativeConnection.Connection.openUri (D:\git_repos\WirVsVirus\Coronahelfer-Hackathon\node_modules\mongoose\lib\connection.js:823:32)
at Mongoose.connect (D:\git_repos\WirVsVirus\Coronahelfer-Hackathon\node_modules\mongoose\lib\index.js:333:15)
at new DBConection (D:\git_repos\WirVsVirus\Coronahelfer-Hackathon\.build\src\config\db\connection.js:13:28)
at Server.dbConfig (D:\git_repos\WirVsVirus\Coronahelfer-Hackathon\.build\src\server.js:31:20)
at new Server (D:\git_repos\WirVsVirus\Coronahelfer-Hackathon\.build\src\server.js:18:14)
at Function.bootstrap (D:\git_repos\WirVsVirus\Coronahelfer-Hackathon\.build\src\server.js:24:16)
at Object.<anonymous> (D:\git_repos\WirVsVirus\Coronahelfer-Hackathon\.build\src\server.js:36:23)
at Module._compile (internal/modules/cjs/loader.js:1151:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1171:10)
at Module.load (internal/modules/cjs/loader.js:1000:32)
at Function.Module._load (internal/modules/cjs/loader.js:899:14)
at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:71:12)
at internal/main/run_main_module.js:17:47 {
message: 'connection <monitor> to <server-ip>:<server-port> closed',
name: 'MongooseServerSelectionError',
reason: TopologyDescription {
type: 'Single',
setName: null,
maxSetVersion: null,
maxElectionId: null,
servers: Map(1) {
'<server-ip>:<server-port>' => [ServerDescription]
},
stale: false,
compatible: true,
compatibilityError: null,
logicalSessionTimeoutMinutes: null,
heartbeatFrequencyMS: 10000,
localThresholdMS: 15,
commonWireVersion: null
},
[Symbol(mongoErrorContextSymbol)]: {}
}