在Debian上测试Mosquitto SSL配置时出现未知的CA.

时间:2017-10-09 22:15:17

标签: debian mosquitto

我正在使用Microsoft Azure中的Debian VM。 我安装了Mosquitto,它运行正常,而我没有配置SSL。 我使用OpenSSL创建了一个自签名证书和密钥(server.crt& server.key):

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

我的主机名是Debian-RNO,我用它作为通用名称。 我的mosquitto.conf是

# mosquitto.conf
pid_file /var/run/mosquitto.pid
persistence true
persistence_location /var/lib/mosquitto/
log_dest file /var/log/mosquitto/mosquitto.log
# MQTT over TLS/SSL
listener 8883
cafile /etc/mosquitto/certs/ca.crt
certfile /etc/mosquitto/certs/server.crt
keyfile /etc/mosquitto/certs/server.key
log_type error
log_type warning
log_type notice
log_type information
tls_version tlsv1.2
# End of MQTT over TLS/SLL configuration

代理启动时没有错误。 当我执行mosquitto_pub时:

mosquitto_pub -h Debian-RNO -t topic1 -m "test" -d --cafile /etc/mosquitto/certs/ca.crt -p 8883

我收到了这个错误:

Unable to connect (A TLS error occurred.).

在mosquitto.log中,我有这些条目:

1507583871: New connection from 52.178.101.16 on port 8883.
1507583871: OpenSSL Error: error:14094418:SSL routines:SSL3_READ_BYTES:tlsv1 alert unknown ca
1507583871: OpenSSL Error: error:140940E5:SSL routines:SSL3_READ_BYTES:ssl handshake failure
1507583871: Socket error on client <unknown>, disconnecting.

我搜索了几个小时没有成功......欢迎任何帮助!

1 个答案:

答案 0 :(得分:0)

SSL3_READ_BYTES:tlsv1 alert unknown ca

这清楚地表明,在ssl握手期间,CA证书不受信任,因为它由您本地生成的CA签名,因此您需要在信任库中导入您的CA证书(操作系统级别或任何信任库mosquitto是使用)