[英]Connecting to AWS documentDB using mongoose giving error: 'MongoParseError: option ssl_ca_certs is not supported'
您好,我只是想使用 mongoose 連接到我的 documentDb; 托管在 AWS 上。 在我的本地電腦上,我嘗試這樣做:
const URI = 'mongodb://username:npassword@docdb-2022-05-31-18-46-43.cluster-cnyrbefiq91q.eu-west-2.docdb.amazonaws.com:27017/?ssl=true&replicaSet=rs0&readPreference=secondaryPreferred&retryWrites=false'
mongoose.connect(URI, { useNewUrlParser: true , ssl: true});
我收到錯誤消息:
MongoParseError: option ssl_ca_certs is not supported
任何人都可以向我解釋我做錯了什么嗎?
DocumentDB 支持 TLS 協議。 它對我有用
1/ 使用下載 TLS 公鑰
wget https://s3.amazonaws.com/rds-downloads/rds-combined-ca-bundle.pem
2/ 將連接字符串中的參數ssl=true
更改為tls=true
,
3/ 並將參數更新為 connect() 方法。
const uri = 'mongodb://<user>:<password>@<clusterAddress>:27017/?tls=true&replicaSet=rs0&readPreference=secondaryPreferred&retryWrites=false'
const client = new MongoClient(uri,{tlsCAFile: `rds-combined-ca-bundle.pem`});
try{
await client.connect();
}
我參考了這個DocumentDB 文檔。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.