簡體   English   中英

如何使用信任庫和密碼指定Kafka AdminClientConfig(Kafka Admin API)

[英]How to specify Kafka AdminClientConfig (Kafka Admin api) With Trust store and Password

如何使用信任庫和密碼創建Kafka AdminClientConfig(Kafka JAVA Admin api)。 AdminClientConfig具有指定AdminClientConfig.BOOTSTRAP_SERVERS_CONFIG的方法,但是如何指定“ ssl.truststore.location”和“ password”屬性呢?

如果我們使用屬性文件,如何使用屬性文件創建AdminClientConfig?

您可以像在其他客戶端中一樣為AdminClient指定SSL配置。

  • 沒有屬性文件:

     Properties adminProps = new Properties(); adminProps.put(...) adminProps.put(SslConfigs.SSL_TRUSTSTORE_LOCATION_CONFIG, "some/path/truststore"); adminProps.put(SslConfigs.SSL_TRUSTSTORE_PASSWORD_CONFIG, "password"); AdminClient admin = KafkaAdminClient.create(adminProps); 
  • 使用屬性文件:

    admin.properties

     bootstrap.servers=localhost:9092 ... ssl.truststore.location=some/path/truststore ssl.truststore.password=password 

    然后在您的Java代碼中:

     Properties adminProps = new Properties(); adminProps.load(new FileInputStream("admin.properties")); AdminClient admin = KafkaAdminClient.create(adminProps); 

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM