How to configure Kafka streaming security?

68 Views Asked by At

We use spring boot in our project. It is required to configure secured spring cloud streaming with kafka. Security connection should be managed using keystore.jks and truststore.jks I tried to find some documentation how to configure ssl concepts. No required information in official spring documentation. I've detected some information at kafka site but I do not know how to connect it with spring cloud streaming. Forum answers that I detected don't work for me. Anyway I think that I need to combine somehow

spring:
  cloud:
    stream:

and

    security:
      protocol: SSL
    ssl:
      key-store-location: ${KEY_STORE_LOCATION}
      key-store-password: ${KEY_STORE_PASSWORD}
      key-store-type: JKS
      key-password: ${KEY_PASSWORD}
      trust-store-location: ${TRUST_STORE_LOCATION}
      trust-store-password: ${TRUST_STORE_PASSWORD}
      trust-store-type: JKS

is there any recommendations or required documentation links?

P.S.

My demo application using kafka streaming works correctly in case topic is not secured?

spring:
  cloud:
    stream:
      bindings:
        input-channel:
          destination: input_topic
        output-channel:
          destination: output_topic
1

There are 1 best solutions below

0
On BEST ANSWER

spring.cloud.stream.kafka.binder.configuration

Key/Value map of client properties (both producers and consumer) passed to all clients created by the binder

So

spring:
  cloud:
    stream: 
      kafka.binder:
        configuration:
          [ssl.security.protocol]: SSL
          [ssl.keystore.location]: /example/key.jks

You'd use dots for the Kafka properties, not dashes... Spring-kafka uses dashes for Boot auto config, not Spring Cloud