Merge branch '154-make-mqtt-client-use-cert' into 'master'

Resolve "Make MQTT client use cert"

Closes #154

See merge request jankstudio/resq!155
This commit is contained in:
Kendrick Chan 2018-07-06 15:47:03 +00:00
commit a87bd31c03
3 changed files with 6 additions and 3 deletions

View file

@ -26,5 +26,5 @@ RT_SHORTCODE=1234
# mosquitto client
MQTT_IP_ADDRESS=localhost
MQTT_PORT=1883
MQTT_PORT=8883
MQTT_CERT=/location/of/cert/file.crt

View file

@ -69,3 +69,4 @@ services:
arguments:
$ip_address: "%env(MQTT_IP_ADDRESS)%"
$port: "%env(MQTT_PORT)%"
$cert: "%env(MQTT_CERT)%"

View file

@ -12,9 +12,11 @@ class MQTTClient
protected $mclient;
public function __construct($ip_address, $port)
public function __construct($ip_address, $port, $cert)
{
$this->mclient = new MosquittoClient();
$this->mclient->setTlsCertificates($cert);
$this->mclient->setTlsOptions(MosquittoClient::SSL_VERIFY_NONE, 'tlsv1');
$this->mclient->connect($ip_address, $port);
}