2
我試圖連接我的RabbitMQ服務器,它被迫使用SSL,並且使用用戶和密碼進行保護。以前,我成功地從C#,PHP和Python應用程序連接到此服務器。如何連接節點的amqplib與ssl連接?
這是我的Node.js代碼:
const amqp = require('amqplib');
const fs = require('fs');
const config = {...}
const opts = {
ca: [fs.readFileSync(config.certificatePath)]
};
const url = `amqps://${config.username}:${config.password}@${config.hostname}:${config.port}`;
const open = amqp.connect(url, opts);
open.then(function(conn) {
console.log('connected.');
}).then(null, console.warn);
我得到的錯誤是:無法獲取本地頒發者證書
1)是什麼錯誤呢?
2)我需要做什麼才能連接?
注意:在library's ssl guide它被寫爲「(必須)提供一個選項對象,將傳遞到tls.connect()
」。 我不明白這個指令,也沒有使用tls.connect()
的例子。我嘗試了一些變化,但失敗了,也許它會給這裏的某個人提供線索。
在你的情況'config.certificatePath'這是正在使用服務器的證書文件? –
其實我試過這兩種方法。一個嘗試使用相同的證書,另一個嘗試使用不同的證書。 –