Permalink
Browse files

mqtt plugin: Add support for TLS in Subscriber blocks.

Fixes: #2419
  • Loading branch information...
octo committed Sep 20, 2017
1 parent ebf73b6 commit 817c07d27d53e63761dd840cefe14db81686dbf9
Showing with 23 additions and 4 deletions.
  1. +5 −0 src/collectd.conf.in
  2. +18 −4 src/mqtt.c
@@ -814,6 +814,11 @@
# QoS 2
# Topic "collectd/#"
# CleanSession true
# CACert "/etc/ssl/ca.crt"
# CertificateFile "/etc/ssl/client.crt"
# CertificateKeyFile "/etc/ssl/client.pem"
# TLSProtocol "tlsv1.2"
# CipherSuite "ciphers"
# </Subscribe>
#</Plugin>
@@ -525,10 +525,10 @@ static int mqtt_write(const data_set_t *ds, const value_list_t *vl,
* StoreRates true
* Retain false
* QoS 0
* CACert "ca.pem" Enables TLS if set
* CertificateFile "client-cert.pem" optional
* CertificateKeyFile "client-key.pem" optional
* TLSProtocol "tlsv1.2" optional
* CACert "ca.pem" Enables TLS if set
* CertificateFile "client-cert.pem" optional
* CertificateKeyFile "client-key.pem" optional
* TLSProtocol "tlsv1.2" optional
* </Publish>
*/
static int mqtt_config_publisher(oconfig_item_t *ci) {
@@ -624,6 +624,10 @@ static int mqtt_config_publisher(oconfig_item_t *ci) {
* User "guest"
* Password "secret"
* Topic "collectd/#"
* CACert "ca.pem" Enables TLS if set
* CertificateFile "client-cert.pem" optional
* CertificateKeyFile "client-key.pem" optional
* TLSProtocol "tlsv1.2" optional
* </Subscribe>
*/
static int mqtt_config_subscriber(oconfig_item_t *ci) {
@@ -687,6 +691,16 @@ static int mqtt_config_subscriber(oconfig_item_t *ci) {
cf_util_get_string(child, &conf->topic);
else if (strcasecmp("CleanSession", child->key) == 0)
cf_util_get_boolean(child, &conf->clean_session);
else if (strcasecmp("CACert", child->key) == 0)
cf_util_get_string(child, &conf->cacertificatefile);
else if (strcasecmp("CertificateFile", child->key) == 0)
cf_util_get_string(child, &conf->certificatefile);
else if (strcasecmp("CertificateKeyFile", child->key) == 0)
cf_util_get_string(child, &conf->certificatekeyfile);
else if (strcasecmp("TLSProtocol", child->key) == 0)
cf_util_get_string(child, &conf->tlsprotocol);
else if (strcasecmp("CipherSuite", child->key) == 0)
cf_util_get_string(child, &conf->ciphersuite);
else
ERROR("mqtt plugin: Unknown config option: %s", child->key);
}

0 comments on commit 817c07d

Please sign in to comment.