How to configure kafka for TLS communication using PEM
encoded files in java client. All the documentation I see out there talks about creating and using java KeyStore
and trustStore
.
https://kafka.apache.org/10/javadoc/index.html?org/apache/kafka/clients/producer/KafkaProducer.html , https://www.confluent.io/blog/apache-kafka-security-authorization-authentication-encryption/ , https://docs.confluent.io/current/kafka/authentication_ssl.html
I have x.509
encoded cert, private_key and ca files, how I use them to connect to kafka in golang (just an example) is something like this
func connect(brokers []string, certs map[string][]byte) {
certpool := x509.NewCertPool()
certpool.AppendCertsFromPEM(certs["ca"])
c, err := tls.X509KeyPair(certs["cert"], certs["private_key"])
tls := tls.Config{
RootCAs: certpool,
ClientAuth: tls.NoClientCert,
ClientCAs: nil,
Certificates: []tls.Certificate{c},
}
config := sarama.NewConfig()
config.Producer.Return.Successes = true
config.Net.TLS.Enable = true
config.Net.TLS.Config = &tls
}
How can I replicate the same behavior in java, maybe I am missing something here but is there any api/documentation that I can refer which lets us configure PEM encoded contents rather than creating keyStore
?