Reputation: 5070
I have a kafka consumer, which consumes messages from a broker.
The consumer needs proper SSL.
Only a cert file and a key file are available.
There is no direct keystore.p12 truststore.p12
I understand I can use some tools such as openSSL, keytool, and other to transform the two into a keystore.p12 truststore.p12 (or jks) before the app starts.
However, I would like to configure the kafka consumer to use the cert and key files directly.
There are many samples online which show the usage of keystore and truststore, like:
final Map<String, Object> properties = new HashMap<>();
properties.put("security.protocol", "SSL");
properties.put(SslConfigs.SSL_KEYSTORE_LOCATION_CONFIG, "/path/to/keystore.p12");
properties.put(SslConfigs.SSL_KEYSTORE_PASSWORD_CONFIG, "keystorepassword");
properties.put(SslConfigs.SSL_TRUSTSTORE_LOCATION_CONFIG, "/path/to/truststore/p12");
properties.put(SslConfigs.SSL_TRUSTSTORE_PASSWORD_CONFIG, "truststorepassword");
properties.put(ConsumerConfig.BOOTSTRAP_SERVERS_CONFIG, "the-ssl-broker.com:9092");
But I would like some help configuring using the cert and key files directly.
I tried looking for some properties properties.put(SslConfigs.SSL_KEY, "/path/to/file.key"
or SslConfigs.SSL_CERTIFICATE, "path/to/file.cert"
but no luck.
I am also using SpringBoot 2, which does not offer the SslBundle.
Question: How to configure the kafka consumer to use the key and cert directly?
Upvotes: 0
Views: 22