[英]Getting error message when I use SSL on my server running Mosquitto?
我已經在端口8883和端口1883上為ubuntu實施了mosquitto代理,無法弄清為什么我仍然收到如下所示的CA相關錯誤。
當我在服務器上本地使用mosquitto_pub測試它時,以及當我在MacBook上使用Paho / Python腳本作為客戶端時,都會發生這種情況。 我的mosquitto.config文件,mosquitto_pub命令和我的mosquitto日志消息如下所示。 我還包括了我的openssl證書創建命令,以防萬一我做錯了什么。
這是我的mosquitto.conf文件
# Place your local configuration in /etc/mosquitto/conf.d/
# A full description of the configuration file is at
# /usr/share/doc/mosquitto/examples/mosquitto.conf.example
pid_file /var/run/mosquitto.pid
persistence true
persistence_location /var/lib/mosquitto/
#log_dest file /var/log/mosquitto/mosquitto.log
log_dest stdout
include_dir /etc/mosquitto/conf.d
log_type all
#-----------------------------------------------
#Default Listener
#-----------------------------------------------
port 8883
#------------------------------------------------
#Certificate Based SSL/TLS Support
#------------------------------------------------
cafile /../etc/mosquitto/ca_certificates/ca.crt
keyfile /../etc/mosquitto/certs/server.key
certfile /../etc/mosquitto/certs/server.crt
listener 1883
這是我用來測試的mosquitto_pub命令。
sudo mosquitto_pub -h 305.875.987.34 -t test -m "Typing this" -p 8883 --cafile /../etc/mosquitto/ca_certificates/ca.crt
這就是我運行蚊帳時所說的話。
1546507891: mosquitto version 1.5.5 starting
1546507891: Config loaded from /../etc/mosquitto/mosquitto.conf.
1546507891: Opening ipv4 listen socket on port 1883.
1546507891: Opening ipv6 listen socket on port 1883.
1546507891: Opening ipv4 listen socket on port 8883.
1546507891: Opening ipv6 listen socket on port 8883.
1546507929: New connection from 305.875.987.34 on port 8883.
1546507929: OpenSSL Error: error:14094418:SSL routines:ssl3_read_bytes:tlsv1 alert unknown ca
1546507929: Socket error on client <unknown>, disconnecting.
這些是我用來創建ca.crt,server.crt和server.key的openssl命令。 我在名為certs的文件夾中創建了它們。
openssl genrsa -des3 -out ca.key 2048
openssl req -new -x509 -days 1826 -key ca.key -out ca.crt
openssl genrsa -out server.key 2048
openssl req -new -out server.csr -key server.key
openssl x509 -req -in server.csr -CA ca.crt -CAkey ca.key -CAcreateserial -out server.crt -days 360
然后,在刪除嘗試修復該問題的舊ca.crt之后,我將ca.crt移至/../etc/mosquitto/ca_certifications。 我使用以下兩個命令執行了此操作。
sudo rm /../etc/mosquitto/ca_certifications/ca.crt
sudo mv ca.crt /../etc/mosquitto/ca_certifications
除了將它們放在/../etc/mosquitto/certs中之外,我對server.crt和server.key進行了相同的操作。
該代理似乎在1883端口上運行良好。
讓我知道您是否需要更多信息。
首先,我將重新排列您的mosquitto.conf
以使內容與內容的聯系更加明顯,並刪除證書/密鑰文件的相對路徑,如下所示:
# Place your local configuration in /etc/mosquitto/conf.d/
# A full description of the configuration file is at
# /usr/share/doc/mosquitto/examples/mosquitto.conf.example
pid_file /var/run/mosquitto.pid
persistence true
persistence_location /var/lib/mosquitto/
#log_dest file /var/log/mosquitto/mosquitto.log
log_dest stdout
include_dir /etc/mosquitto/conf.d
log_type all
#-----------------------------------------------
#Default Listener
#-----------------------------------------------
port 1883
#------------------------------------------------
#Certificate Based SSL/TLS Support
#------------------------------------------------
listener 8883
cafile /etc/mosquitto/ca_certificates/ca.crt
keyfile /etc/mosquitto/certs/server.key
certfile /etc/mosquitto/certs/server.crt
我交換了端口/偵聽器條目,以很明顯地將SSL設置綁定到端口8883偵聽器。 我還從路徑的開頭刪除了/../,因為這是沒有意義的,因為不可能從“ /”根目錄“上”到一個目錄。
同樣,您應該對mosquitto_pub命令使用直接路徑。
同樣,當您以root身份(使用sudo)復制文件時,請確保mosquitto用戶可以讀取cert / key文件。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.