Posts

Showing posts with the label mqtt

2 way Secured Mosquitto MQTT error

2 way Secured Mosquitto MQTT error I'm new to MQTT. I create a mosquitto broker with ssl and connect successfully. My commands to create certificates as: openssl req -new -x509 -days durations -keyout mqtt_ca.key -out mqtt_ca.crt openssl genrsa -des3 -out mqtt_server.key size_bits openssl req -out mqtt_server.csr -key mqtt_server.key -new openssl x509 -req -in mqtt_server.csr -CA mqtt_ca.crt -CAkey mqtt_ca.key -CAcreateserial -out mqtt_server.crt -days durations* In mosquitto.conf: port 8883 cafile your_path/mqtt_ca.crt certfile your_path/mqtt_server.crt keyfile your_path/mqtt_server.key require_certificate false tls_version tlsv1.1 But it is just one way connection. I want to set `require_certificate true but I don't know how to create client certificates and modify mosquitto.conf. Please show me how to do that. Thank you so much! 1 Answer 1 Creating a Certificate Authority is too detailed ...

Can't Run Mosquitto Commands in PHP

Can't Run Mosquitto Commands in PHP I cannot run the mosquitto_sub or pub commands through the PHP system(), exec(), shell_exec(), etc. Other commands (like hostname and ls) will echo and work fine. Is there something I'm missing? Here's what I have: <?php $message = '{"state":{"desired":{"LED":"ON"}}}'; $cmd = "mosquitto_pub --cafile /var/www/subsystem/crt/rootCA.pem --cert /var/www/subsystem/crt/crt.pem --key /var/www/subsystem/crt/private.pem -h myendpoint.amazonaws.com -p 8883 -t '" . "$" . "aws/things/LED/shadow/update' -m '" . $message . "'"; echo system($cmd); ?> (I know that the string won't parse right with the indenting, and in my PHP file the $cmd variable is a single line.) PS: I've also tried echoing $cmd and copy/pasting that straight to shell, and it works unaltered. Thanks! What's the output of the command? Als...