Modify MQTTClient service to support tls certs #154
This commit is contained in:
parent
6df440f887
commit
550d1e1e02
3 changed files with 6 additions and 3 deletions
|
|
@ -26,5 +26,5 @@ RT_SHORTCODE=1234
|
||||||
|
|
||||||
# mosquitto client
|
# mosquitto client
|
||||||
MQTT_IP_ADDRESS=localhost
|
MQTT_IP_ADDRESS=localhost
|
||||||
MQTT_PORT=1883
|
MQTT_PORT=8883
|
||||||
|
MQTT_CERT=/location/of/cert/file.crt
|
||||||
|
|
|
||||||
|
|
@ -69,3 +69,4 @@ services:
|
||||||
arguments:
|
arguments:
|
||||||
$ip_address: "%env(MQTT_IP_ADDRESS)%"
|
$ip_address: "%env(MQTT_IP_ADDRESS)%"
|
||||||
$port: "%env(MQTT_PORT)%"
|
$port: "%env(MQTT_PORT)%"
|
||||||
|
$cert: "%env(MQTT_CERT)%"
|
||||||
|
|
|
||||||
|
|
@ -12,9 +12,11 @@ class MQTTClient
|
||||||
|
|
||||||
protected $mclient;
|
protected $mclient;
|
||||||
|
|
||||||
public function __construct($ip_address, $port)
|
public function __construct($ip_address, $port, $cert)
|
||||||
{
|
{
|
||||||
$this->mclient = new MosquittoClient();
|
$this->mclient = new MosquittoClient();
|
||||||
|
$this->mclient->setTlsCertificates($cert);
|
||||||
|
$this->mclient->setTlsOptions(MosquittoClient::SSL_VERIFY_NONE, 'tlsv1');
|
||||||
$this->mclient->connect($ip_address, $port);
|
$this->mclient->connect($ip_address, $port);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue