Browse Source

Merge pull request #8342 from volodymyr-babak/ssl-option-kafka

[3.5] Add SSL option for Kafka queue connection
pull/8351/head
Andrew Shvayka 3 years ago
committed by GitHub
parent
commit
bc5d6ea359
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 7
      application/src/main/resources/thingsboard.yml
  2. 37
      common/queue/src/main/java/org/thingsboard/server/queue/kafka/TbKafkaSettings.java
  3. 7
      msa/vc-executor/src/main/resources/tb-vc-executor.yml
  4. 7
      transport/coap/src/main/resources/tb-coap-transport.yml
  5. 7
      transport/http/src/main/resources/tb-http-transport.yml
  6. 7
      transport/lwm2m/src/main/resources/tb-lwm2m-transport.yml
  7. 7
      transport/mqtt/src/main/resources/tb-mqtt-transport.yml
  8. 7
      transport/snmp/src/main/resources/tb-snmp-transport.yml

7
application/src/main/resources/thingsboard.yml

@ -988,6 +988,13 @@ queue:
print-interval-ms: "${TB_QUEUE_IN_MEMORY_STATS_PRINT_INTERVAL_MS:60000}"
kafka:
bootstrap.servers: "${TB_KAFKA_SERVERS:localhost:9092}"
ssl:
enabled: "${TB_KAFKA_SSL_ENABLED:false}"
truststore.location: "${TB_KAFKA_SSL_TRUSTSTORE_LOCATION:}"
truststore.password: "${TB_KAFKA_SSL_TRUSTSTORE_PASSWORD:}"
keystore.location: "${TB_KAFKA_SSL_KEYSTORE_LOCATION:}"
keystore.password: "${TB_KAFKA_SSL_KEYSTORE_PASSWORD:}"
key.password: "${TB_KAFKA_SSL_KEY_PASSWORD:}"
acks: "${TB_KAFKA_ACKS:all}"
retries: "${TB_KAFKA_RETRIES:1}"
compression.type: "${TB_KAFKA_COMPRESSION_TYPE:none}" # none or gzip

37
common/queue/src/main/java/org/thingsboard/server/queue/kafka/TbKafkaSettings.java

@ -19,6 +19,7 @@ import lombok.Getter;
import lombok.Setter;
import lombok.extern.slf4j.Slf4j;
import org.apache.kafka.clients.CommonClientConfigs;
import org.apache.kafka.common.config.SslConfigs;
import org.apache.kafka.clients.admin.AdminClientConfig;
import org.apache.kafka.clients.consumer.ConsumerConfig;
import org.apache.kafka.clients.producer.ProducerConfig;
@ -49,6 +50,24 @@ public class TbKafkaSettings {
@Value("${queue.kafka.bootstrap.servers}")
private String servers;
@Value("${queue.kafka.ssl.enabled:false}")
private boolean sslEnabled;
@Value("${queue.kafka.ssl.truststore.location}")
private String sslTruststoreLocation;
@Value("${queue.kafka.ssl.truststore.password}")
private String sslTruststorePassword;
@Value("${queue.kafka.ssl.keystore.location}")
private String sslKeystoreLocation;
@Value("${queue.kafka.ssl.keystore.password}")
private String sslKeystorePassword;
@Value("${queue.kafka.ssl.key.password}")
private String sslKeyPassword;
@Value("${queue.kafka.acks}")
private String acks;
@ -115,6 +134,8 @@ public class TbKafkaSettings {
props.put(AdminClientConfig.BOOTSTRAP_SERVERS_CONFIG, servers);
props.put(AdminClientConfig.RETRIES_CONFIG, retries);
configureSSL(props);
return props;
}
@ -126,6 +147,8 @@ public class TbKafkaSettings {
props.put(ConsumerConfig.FETCH_MAX_BYTES_CONFIG, fetchMaxBytes);
props.put(ConsumerConfig.MAX_POLL_INTERVAL_MS_CONFIG, maxPollIntervalMs);
configureSSL(props);
props.put(ConsumerConfig.KEY_DESERIALIZER_CLASS_CONFIG, StringDeserializer.class);
props.put(ConsumerConfig.VALUE_DESERIALIZER_CLASS_CONFIG, ByteArrayDeserializer.class);
@ -164,7 +187,21 @@ public class TbKafkaSettings {
if (other != null) {
other.forEach(kv -> props.put(kv.getKey(), kv.getValue()));
}
configureSSL(props);
return props;
}
private void configureSSL(Properties props) {
if (sslEnabled) {
props.put(CommonClientConfigs.SECURITY_PROTOCOL_CONFIG, "SSL");
props.put(SslConfigs.SSL_TRUSTSTORE_LOCATION_CONFIG, sslTruststoreLocation);
props.put(SslConfigs.SSL_TRUSTSTORE_PASSWORD_CONFIG, sslTruststorePassword);
props.put(SslConfigs.SSL_KEYSTORE_LOCATION_CONFIG, sslKeystoreLocation);
props.put(SslConfigs.SSL_KEYSTORE_PASSWORD_CONFIG, sslKeystorePassword);
props.put(SslConfigs.SSL_KEY_PASSWORD_CONFIG, sslKeyPassword);
}
}
}

7
msa/vc-executor/src/main/resources/tb-vc-executor.yml

@ -50,6 +50,13 @@ queue:
print-interval-ms: "${TB_QUEUE_IN_MEMORY_STATS_PRINT_INTERVAL_MS:60000}"
kafka:
bootstrap.servers: "${TB_KAFKA_SERVERS:localhost:9092}"
ssl:
enabled: "${TB_KAFKA_SSL_ENABLED:false}"
truststore.location: "${TB_KAFKA_SSL_TRUSTSTORE_LOCATION:}"
truststore.password: "${TB_KAFKA_SSL_TRUSTSTORE_PASSWORD:}"
keystore.location: "${TB_KAFKA_SSL_KEYSTORE_LOCATION:}"
keystore.password: "${TB_KAFKA_SSL_KEYSTORE_PASSWORD:}"
key.password: "${TB_KAFKA_SSL_KEY_PASSWORD:}"
acks: "${TB_KAFKA_ACKS:all}"
retries: "${TB_KAFKA_RETRIES:1}"
compression.type: "${TB_KAFKA_COMPRESSION_TYPE:none}" # none or gzip

7
transport/coap/src/main/resources/tb-coap-transport.yml

@ -151,6 +151,13 @@ queue:
type: "${TB_QUEUE_TYPE:kafka}" # kafka (Apache Kafka) or aws-sqs (AWS SQS) or pubsub (PubSub) or service-bus (Azure Service Bus) or rabbitmq (RabbitMQ)
kafka:
bootstrap.servers: "${TB_KAFKA_SERVERS:localhost:9092}"
ssl:
enabled: "${TB_KAFKA_SSL_ENABLED:false}"
truststore.location: "${TB_KAFKA_SSL_TRUSTSTORE_LOCATION:}"
truststore.password: "${TB_KAFKA_SSL_TRUSTSTORE_PASSWORD:}"
keystore.location: "${TB_KAFKA_SSL_KEYSTORE_LOCATION:}"
keystore.password: "${TB_KAFKA_SSL_KEYSTORE_PASSWORD:}"
key.password: "${TB_KAFKA_SSL_KEY_PASSWORD:}"
acks: "${TB_KAFKA_ACKS:all}"
retries: "${TB_KAFKA_RETRIES:1}"
compression.type: "${TB_KAFKA_COMPRESSION_TYPE:none}" # none or gzip

7
transport/http/src/main/resources/tb-http-transport.yml

@ -136,6 +136,13 @@ queue:
type: "${TB_QUEUE_TYPE:kafka}" # kafka (Apache Kafka) or aws-sqs (AWS SQS) or pubsub (PubSub) or service-bus (Azure Service Bus) or rabbitmq (RabbitMQ)
kafka:
bootstrap.servers: "${TB_KAFKA_SERVERS:localhost:9092}"
ssl:
enabled: "${TB_KAFKA_SSL_ENABLED:false}"
truststore.location: "${TB_KAFKA_SSL_TRUSTSTORE_LOCATION:}"
truststore.password: "${TB_KAFKA_SSL_TRUSTSTORE_PASSWORD:}"
keystore.location: "${TB_KAFKA_SSL_KEYSTORE_LOCATION:}"
keystore.password: "${TB_KAFKA_SSL_KEYSTORE_PASSWORD:}"
key.password: "${TB_KAFKA_SSL_KEY_PASSWORD:}"
acks: "${TB_KAFKA_ACKS:all}"
retries: "${TB_KAFKA_RETRIES:1}"
compression.type: "${TB_KAFKA_COMPRESSION_TYPE:none}" # none or gzip

7
transport/lwm2m/src/main/resources/tb-lwm2m-transport.yml

@ -217,6 +217,13 @@ queue:
type: "${TB_QUEUE_TYPE:kafka}" # kafka (Apache Kafka) or aws-sqs (AWS SQS) or pubsub (PubSub) or service-bus (Azure Service Bus) or rabbitmq (RabbitMQ)
kafka:
bootstrap.servers: "${TB_KAFKA_SERVERS:localhost:9092}"
ssl:
enabled: "${TB_KAFKA_SSL_ENABLED:false}"
truststore.location: "${TB_KAFKA_SSL_TRUSTSTORE_LOCATION:}"
truststore.password: "${TB_KAFKA_SSL_TRUSTSTORE_PASSWORD:}"
keystore.location: "${TB_KAFKA_SSL_KEYSTORE_LOCATION:}"
keystore.password: "${TB_KAFKA_SSL_KEYSTORE_PASSWORD:}"
key.password: "${TB_KAFKA_SSL_KEY_PASSWORD:}"
acks: "${TB_KAFKA_ACKS:all}"
retries: "${TB_KAFKA_RETRIES:1}"
compression.type: "${TB_KAFKA_COMPRESSION_TYPE:none}" # none or gzip

7
transport/mqtt/src/main/resources/tb-mqtt-transport.yml

@ -166,6 +166,13 @@ queue:
type: "${TB_QUEUE_TYPE:kafka}" # kafka (Apache Kafka) or aws-sqs (AWS SQS) or pubsub (PubSub) or service-bus (Azure Service Bus) or rabbitmq (RabbitMQ)
kafka:
bootstrap.servers: "${TB_KAFKA_SERVERS:localhost:9092}"
ssl:
enabled: "${TB_KAFKA_SSL_ENABLED:false}"
truststore.location: "${TB_KAFKA_SSL_TRUSTSTORE_LOCATION:}"
truststore.password: "${TB_KAFKA_SSL_TRUSTSTORE_PASSWORD:}"
keystore.location: "${TB_KAFKA_SSL_KEYSTORE_LOCATION:}"
keystore.password: "${TB_KAFKA_SSL_KEYSTORE_PASSWORD:}"
key.password: "${TB_KAFKA_SSL_KEY_PASSWORD:}"
acks: "${TB_KAFKA_ACKS:all}"
retries: "${TB_KAFKA_RETRIES:1}"
compression.type: "${TB_KAFKA_COMPRESSION_TYPE:none}" # none or gzip

7
transport/snmp/src/main/resources/tb-snmp-transport.yml

@ -112,6 +112,13 @@ queue:
type: "${TB_QUEUE_TYPE:kafka}" # kafka (Apache Kafka) or aws-sqs (AWS SQS) or pubsub (PubSub) or service-bus (Azure Service Bus) or rabbitmq (RabbitMQ)
kafka:
bootstrap.servers: "${TB_KAFKA_SERVERS:localhost:9092}"
ssl:
enabled: "${TB_KAFKA_SSL_ENABLED:false}"
truststore.location: "${TB_KAFKA_SSL_TRUSTSTORE_LOCATION:}"
truststore.password: "${TB_KAFKA_SSL_TRUSTSTORE_PASSWORD:}"
keystore.location: "${TB_KAFKA_SSL_KEYSTORE_LOCATION:}"
keystore.password: "${TB_KAFKA_SSL_KEYSTORE_PASSWORD:}"
key.password: "${TB_KAFKA_SSL_KEY_PASSWORD:}"
acks: "${TB_KAFKA_ACKS:all}"
retries: "${TB_KAFKA_RETRIES:1}"
compression.type: "${TB_KAFKA_COMPRESSION_TYPE:none}" # none or gzip

Loading…
Cancel
Save