2017-10-23 11 views
0

私は蚊帳サーバとクライアントをインストールしたubuntuの17.04バージョンを実行しています。 /etc/mosquitto/ca_certificatesMQTT tls/sslは、mqtt-spyおよびmqttfxを使用してパブリッシュ/サブスクライブします。 mosquitto_subの正しいパラメータは何ですか?

にそれらを配置し、それに応じてmosquitto.confを構成し

openssl genrsa -out ca.key 2048 
openssl req -x509 -new -nodes -key ca.key -sha256 -days 3650 -out ca.crt 
openssl genrsa -out server.key 2048 
openssl req -new -key server.key -out server.csr 
openssl x509 -req -in server.csr -CA ca.crt -CAkey ca.key -CAcreateserial -out server.crt -days 3650 -sha256 

[email protected]:~/mosquitto$ cd /etc/mosquitto/ca_certificates/ 
[email protected]:/etc/mosquitto/ca_certificates$ ls 
ca.crt ca.key ca.srl server.crt server.csr server.key 
[email protected]:/etc/mosquitto/ca_certificates$ cd .. 
[email protected]:/etc/mosquitto$ cat 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 

include_dir /etc/mosquitto/conf.d 

listener 8883 

cafile /etc/mosquitto/ca_certificates/ca.crt 
certfile /etc/mosquitto/ca_certificates/server.crt 
keyfile /etc/mosquitto/ca_certificates/server.key 

MQTT-スパイ/ MQTTFXは問題を接続しない:

私は証明書のセットを生成しましたConnection String MQTTFX enter image description here

しかし、mosquitto_pub/mosquitto_sub以上のメッセージを公開/購読するにはどうすればよいですか?

[email protected]:~$ mosquitto_sub -h localhost -p 8883 -t sensors/room1/temp01 --cafile /etc/mosquitto/ca_certificates/ca.crt 
Unable to connect (A TLS error occurred.). 
[email protected]:~$ mosquitto_sub -p 8883 -t sensors/room1/temp01 --cafile /etc/mosquitto/ca_certificates/ca.crt 
Unable to connect (A TLS error occurred.). 
[email protected]:/tmp$ mosquitto_pub -p 8883 -t sensors/room1/temp01 --cafile /etc/mosquitto/ca_certificates/ca.crt -m "150 f" -d 
Unable to connect (A TLS error occurred.). 
[email protected]:/tmp$ mosquitto_pub -p 8883 -t sensors/room1/temp01 --cafile /etc/mosquitto/ca_certificates/ca.crt -m "150 f" -d --tls-version tlsv1.2 
Unable to connect (A TLS error occurred.). 

mosquitto.logファイルレポート:

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

EDIT:

[email protected]:~/mosquitto$ openssl req -new -key server.key -out server.csr 
You are about to be asked to enter information that will be incorporated 
into your certificate request. 
What you are about to enter is what is called a Distinguished Name or a DN. 
There are quite a few fields but you can leave some blank 
For some fields there will be a default value, 
If you enter '.', the field will be left blank. 
----- 
Country Name (2 letter code) [AU]:DE 
State or Province Name (full name) [Some-State]: 
Locality Name (eg, city) []: 
Organization Name (eg, company) [Internet Widgits Pty Ltd]: 
Organizational Unit Name (eg, section) []: 
Common Name (e.g. server FQDN or YOUR name) []: 
Email Address []: 

Please enter the following 'extra' attributes 
to be sent with your certificate request 
A challenge password []: 
An optional company name []: 
+0

証明書にはどのようなCN /ホスト名が設定されていますか? – hardillb

+0

私はCN証明書を生成していたときにubuntuシステムがホスト名を要求していません – arthur

+0

マシンを識別するための証明書のホスト名であるべきCNを要求しました – hardillb

答えて

1

全く同じ問題が私に起こります。

私の場合、RB00を使用しているので、私は同じCN=broker'sホスト名、raspberrypiを設定しました。

+0

ホストの名前を設定する方法? – arthur

+0

まあ、それはシステムによって異なります。マシンの名前を設定する方法 –

+0

... hostnameコマンド の/ etc /ホスト名 の/ etc/sysconfig/networkファイル することができことは私には明らかです。それは「デイジー」と呼ばれています。私はそれをどうしますか? – arthur

2

私たちが最初に学んだことは、証明書のCNの検証を妨げる--insecureオプションです。

関連する問題