Я могу публиковать sh и подписываться на сообщения через брокера ActiveMQ без использования SSL.
Теперь я хочу использовать ActiveMQ с SSL. Я использую самозаверяющие сертификаты.
Я выполнил шаги, указанные в этой ссылке: http://activemq.apache.org/how-do-i-use-ssl.html для настройки моего брокера.
Поскольку мне нужно использовать сертификаты в формате .pem для моего встроенного устройства, я преобразовал сертификаты в формат .pem.
Когда я пытаюсь подключить esp32 / MQTTfx (настольное приложение) к брокеру , я получаю следующее сообщение об ошибке от брокера:
2020-06-15 12:10:14,037 | DEBUG | Transport Connection to: tcp://---.---.1.5:35182 failed: java.net.ProtocolException: Invalid message encoding | org.apache.activemq.broker.TransportConnection.Transport | ActiveMQ Transport: tcp:///---.---.1.5:35182@1883
java.net.ProtocolException: Invalid message encoding
at org.fusesource.mqtt.codec.MessageSupport.readUTF(MessageSupport.java:63)[mqtt-client-1.12.jar:1.12]
at org.fusesource.mqtt.codec.CONNECT.decode(CONNECT.java:79)[mqtt-client-1.12.jar:1.12]
at org.apache.activemq.transport.mqtt.MQTTProtocolConverter.onMQTTCommand(MQTTProtocolConverter.java:200)[activemq-mqtt-5.13.0.jar:5.13.0]
at org.apache.activemq.transport.mqtt.MQTTTransportFilter.onCommand(MQTTTransportFilter.java:94)[activemq-mqtt-5.13.0.jar:5.13.0]
at org.apache.activemq.transport.TransportSupport.doConsume(TransportSupport.java:83)[activemq-client-5.13.0.jar:5.13.0]
at org.apache.activemq.transport.tcp.TcpTransport.doRun(TcpTransport.java:233)[activemq-client-5.13.0.jar:5.13.0]
at org.apache.activemq.transport.tcp.TcpTransport.run(TcpTransport.java:215)[activemq-client-5.13.0.jar:5.13.0]
at java.lang.Thread.run(Thread.java:745)[:1.8.0_92]
2020-06-15 12:10:14,040 | DEBUG | Unregistering MBean org.apache.activemq:type=Broker,brokerName=localhost,connector=clientConnectors,connectorName=mqtt,connectionViewType=remoteAddress,connectionName=tcp_//---.---.1.5_35182 | org.apache.activemq.broker.jmx.ManagementContext | ActiveMQ Transport: tcp:///---.---.1.5:35182@1883
2020-06-15 12:10:14,041 | DEBUG | Stopping connection: tcp://---.---.1.5:35182 | org.apache.activemq.broker.TransportConnection | ActiveMQ BrokerService[localhost] Task-2185
2020-06-15 12:10:14,041 | WARN | Exception occurred processing:
MQTTFrame { type: unknown, qos: AT_MOST_ONCE, dup:false }: org.apache.activemq.transport.mqtt.MQTTProtocolException: Unknown MQTTFrame type: 0 | org.apache.activemq.transport.mqtt.MQTTProtocolConverter | ActiveMQ Transport: tcp:///---.---.1.5:35182@1883
2020-06-15 12:10:14,042 | DEBUG | Exception detail | org.apache.activemq.transport.mqtt.MQTTProtocolConverter | ActiveMQ Transport: tcp:///---.---.1.5:35182@1883
org.apache.activemq.transport.mqtt.MQTTProtocolException: Unknown MQTTFrame type: 0
at org.apache.activemq.transport.mqtt.MQTTProtocolConverter.onMQTTCommand(MQTTProtocolConverter.java:230)[activemq-mqtt-5.13.0.jar:5.13.0]
at org.apache.activemq.transport.mqtt.MQTTTransportFilter.onCommand(MQTTTransportFilter.java:94)[activemq-mqtt-5.13.0.jar:5.13.0]
at org.apache.activemq.transport.TransportSupport.doConsume(TransportSupport.java:83)[activemq-client-5.13.0.jar:5.13.0]
at org.apache.activemq.transport.tcp.TcpTransport.doRun(TcpTransport.java:233)[activemq-client-5.13.0.jar:5.13.0]
at org.apache.activemq.transport.tcp.TcpTransport.run(TcpTransport.java:215)[activemq-client-5.13.0.jar:5.13.0]
at java.lang.Thread.run(Thread.java:745)[:1.8.0_92]
2020-06-15 12:10:14,042 | DEBUG | Stopping transport tcp:///---.---.1.5:35182@1883 | org.apache.activemq.transport.tcp.TcpTransport | ActiveMQ BrokerService[localhost] Task-2185
2020-06-15 12:10:14,045 | DEBUG | Initialized TaskRunnerFactory[ActiveMQ Task] using ExecutorService: java.util.concurrent.ThreadPoolExecutor@384c5a21[Running, pool size = 0, active threads = 0, queued tasks = 0, completed tasks = 0] | org.apache.activemq.thread.TaskRunnerFactory | ActiveMQ BrokerService[localhost] Task-2185
2020-06-15 12:10:14,047 | DEBUG | Closed socket Socket[addr=/---.---.1.5,port=35182,localport=1883] | org.apache.activemq.transport.tcp.TcpTransport | ActiveMQ Task-1
2020-06-15 12:10:14,049 | DEBUG | Forcing shutdown of ExecutorService: java.util.concurrent.ThreadPoolExecutor@384c5a21[Running, pool size = 1, active threads = 0, queued tasks = 0, completed tasks = 1] | org.apache.activemq.util.ThreadPoolUtils | ActiveMQ BrokerService[localhost] Task-2185
2020-06-15 12:10:14,054 | DEBUG | Stopped transport: tcp://---.---.1.5:35182 | org.apache.activemq.broker.TransportConnection | ActiveMQ BrokerService[localhost] Task-2185
2020-06-15 12:10:14,056 | DEBUG | Connection Stopped: tcp://---.---.1.5:35182 | org.apache.activemq.broker.TransportConnection | ActiveMQ BrokerService[localhost] Task-2185
Ниже приведено сообщение об ошибке, которое я получаю от MQTTfx:
INFO --- BrokerConnectorController : onConnect
INFO --- ScriptsController : Clear console.
INFO --- MqttFX ClientModel : MqttClient with ID xxxxxx assigned.
ERROR --- MqttFX ClientModel : Error when connecting
org.eclipse.paho.client.mqttv3.MqttException: MqttException
at org.eclipse.paho.client.mqttv3.internal.ExceptionHelper.createMqttException(ExceptionHelper.java:38) ~[org.eclipse.paho.client.mqttv3-1.2.0.jar:?]
at org.eclipse.paho.client.mqttv3.internal.ClientComms$ConnectBG.run(ClientComms.java:715) ~[org.eclipse.paho.client.mqttv3-1.2.0.jar:?]
at java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source) ~[?:1.8.0_181]
at java.util.concurrent.FutureTask.run(Unknown Source) ~[?:1.8.0_181]
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201(Unknown Source) ~[?:1.8.0_181]
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(Unknown Source) ~[?:1.8.0_181]
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source) [?:1.8.0_181]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source) [?:1.8.0_181]
at java.lang.Thread.run(Unknown Source) [?:1.8.0_181]
Caused by: javax.net.ssl.SSLHandshakeException: Remote host closed connection during handshake
at sun.security.ssl.SSLSocketImpl.readRecord(Unknown Source) ~[?:1.8.0_181]
at sun.security.ssl.SSLSocketImpl.performInitialHandshake(Unknown Source) ~[?:1.8.0_181]
at sun.security.ssl.SSLSocketImpl.startHandshake(Unknown Source) ~[?:1.8.0_181]
at sun.security.ssl.SSLSocketImpl.startHandshake(Unknown Source) ~[?:1.8.0_181]
at org.eclipse.paho.client.mqttv3.internal.SSLNetworkModule.start(SSLNetworkModule.java:108) ~[org.eclipse.paho.client.mqttv3-1.2.0.jar:?]
at org.eclipse.paho.client.mqttv3.internal.ClientComms$ConnectBG.run(ClientComms.java:701) ~[org.eclipse.paho.client.mqttv3-1.2.0.jar:?]
... 7 more
Caused by: java.io.EOFException: SSL peer shut down incorrectly
at sun.security.ssl.InputRecord.read(Unknown Source) ~[?:1.8.0_181]
at sun.security.ssl.SSLSocketImpl.readRecord(Unknown Source) ~[?:1.8.0_181]
at sun.security.ssl.SSLSocketImpl.performInitialHandshake(Unknown Source) ~[?:1.8.0_181]
at sun.security.ssl.SSLSocketImpl.startHandshake(Unknown Source) ~[?:1.8.0_181]
at sun.security.ssl.SSLSocketImpl.startHandshake(Unknown Source) ~[?:1.8.0_181]
at org.eclipse.paho.client.mqttv3.internal.SSLNetworkModule.start(SSLNetworkModule.java:108) ~[org.eclipse.paho.client.mqttv3-1.2.0.jar:?]
at org.eclipse.paho.client.mqttv3.internal.ClientComms$ConnectBG.run(ClientComms.java:701) ~[org.eclipse.paho.client.mqttv3-1.2.0.jar:?]
... 7 more
ERROR --- MqttFX ClientModel : Please verify your Settings (e.g. Broker Address, Broker Port & Client ID) and the user credentials!
Использование MQTT версии 3.1. 1 как для брокера, так и для клиента.
Так что же мне не хватает? Любая помощь по этому поводу будет принята с благодарностью. Спасибо.