2015-12-11 22 views
3

我正在使用Mqtt協議與節點進行通信的應用程序。我在Windows上使用Mosquitto作爲經紀人。我想使用Mosquitto的SSL/TLS功能來提供安全的身份驗證和消息傳遞機制。我創建相關證書並在mosquitto.conf文件中進行配置。但是,當我嘗試從命令提示符加載mosquitto.conf並重新啓動mosquitto服務時,該服務無法啓動並出現錯誤。我會解釋我做了什麼;如何在Mosquitto上提供基於SSL/TLS的通信?

1)我使用OpenSSL創建了證書。我遵循「https://eclipse.org/mosquitto/man/mosquitto-tls-7.php」的說明。 首先,我創建了ca.crt(根CA證書); enter image description here

相關證書信息如上所示。我還輸入了「trialca」作爲ca.crt的PEM密碼。然後,我創建了server.key(我使用「trialsrv」作爲密碼),server.csr和server.crt; enter image description here; enter image description here

2)我在mosquitto.conf上做了一些配置;

cafile /demo/ca.crt 

certfile /demo/server.crt 

keyfile /server.key 

require_certificate true 

use_identity_as_username true 

注:我使用默認的監聽端口1883

3)我從命令提示符加載mosquitto.conf在PC上運行Mosquitto服務器上。

c:\Program Files (x86)\mosquitto> mosquitto -c mosquitto.conf 

然後,我從Windows上的Services重新啓動了Mosquitto服務。但是,它無法啓動並出現錯誤。 enter image description here

我有什麼不對嗎?我需要你的建議來解決這個問題。

回答

2

今天下午我有同樣的問題。我通過刪除服務器密鑰中的密碼來解決它。命令行exe不需要pw,服務啓動時沒有出現該錯誤。

生成證書後,運行此操作。 (重命名server.key到server.key.org第一)

openssl rsa -in server.key.org -out server.key 

https://webmasters.stackexchange.com/questions/1247/can-i-skip-the-pem-pass-phrase-question-when-i-restart-the-webserver

+0

其實,刪除密碼可能不是一個正確的解決方案,但它讓我繼續前進。十分感謝 :) –

1

如果您已經從命令行啓動了一個mosquitto實例,那麼將其作爲服務啓動將不起作用,因爲第一個已經在運行相同的配置。

+0

感謝您的建議,但也有一些在不同的問題。我已經解決了,謝謝你。 –

相關問題