'Specify SSL details for Kafka brokers in python

I need to connect to kafka instance which has multiple brokers with SSL. I am using kafka-python to consume and process data.

I have seen link where they used kafka-python to connect to single broker with SSL.

Link : http://maximilianchrist.com/python/databases/2016/08/13/connect-to-apache-kafka-from-python-using-ssl.html

Specific code

consumer = KafkaConsumer(bootstrap_servers='my.server.com',
                          security_protocol='SSL',
                          ssl_check_hostname=True,
                          ssl_cafile='CARoot.pem',
                          ssl_certfile='certificate.pem',
                          ssl_keyfile='key.pem')

I need to know since there are multiple brokers how to specify multiple ssl_ca, ssl_cert, ssl_key in constructor ??



Solution 1:[1]

SSL should be set up such that the client can authenticate with any of your brokers. I recommend you take a look at this tutorial to get a better idea on SSL basics https://docs.confluent.io/current/kafka/encryption.html#kafka-ssl-encryption

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 dawsaw