Skip to content

Commit

Permalink
mqtt plugin: Add support for TLS in Subscriber blocks.
Browse files Browse the repository at this point in the history
Fixes: #2419
  • Loading branch information
octo committed Sep 20, 2017
1 parent ebf73b6 commit 817c07d
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 4 deletions.
5 changes: 5 additions & 0 deletions src/collectd.conf.in
Expand Up @@ -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>

Expand Down
22 changes: 18 additions & 4 deletions src/mqtt.c
Expand Up @@ -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) {
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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);
}
Expand Down

0 comments on commit 817c07d

Please sign in to comment.