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
|
||||
MQTT_IP_ADDRESS=localhost
|
||||
MQTT_PORT=1883
|
||||
|
||||
MQTT_PORT=8883
|
||||
MQTT_CERT=/location/of/cert/file.crt
|
||||
|
|
|
|||
|
|
@ -69,3 +69,4 @@ services:
|
|||
arguments:
|
||||
$ip_address: "%env(MQTT_IP_ADDRESS)%"
|
||||
$port: "%env(MQTT_PORT)%"
|
||||
$cert: "%env(MQTT_CERT)%"
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue