【问题标题】:How to connect to Kafka cluster with Kerberos Authentication on Windows using the Cofluent library?如何使用 Cofluent 库在 Windows 上通过 Kerberos 身份验证连接到 Kafka 集群?
【发布时间】:2023-04-04 01:15:01
【问题描述】:

我正在开展一个项目,该项目需要我使用 dotnet 和 Confluent 库连接到现有的 Kafka 集群。 Kafka 集群使用 Kerberous/Keytab 身份验证。查看一些documentation 看起来您可以使用 JAAS 配置通过 keytab 文件,但是当我查看 Confluent 中 ProudcerConfig 的属性时,我看不到任何有关身份验证的信息。那么如何指定 keytab 文件以便我可以针对 Kafka 集群进行身份验证?

【问题讨论】:

    标签: asp.net .net-core apache-kafka kerberos


    【解决方案1】:

    我认为this section of Confluent docs 提到了如何配置客户端:

    在您的 client.properties 文件中,您需要以下配置:

    sasl.mechanism=GSSAPI
    # Configure SASL_SSL if SSL encryption is enabled, otherwise configure SASL_PLAINTEXT
    security.protocol=SASL_SSL
    
    sasl.kerberos.service.name=kafka
    
    sasl.jaas.config=com.sun.security.auth.module.Krb5LoginModule required \
        useKeyTab=true \
        storeKey=true \
        keyTab="/etc/security/keytabs/kafka_client.keytab" \
        principal="kafkaclient1@EXAMPLE.COM";
    
    # optionally - kafka-console-consumer or kafka-console-producer, kinit can be used along with useTicketCache=true
    sasl.jaas.config=com.sun.security.auth.module.Krb5LoginModule required \
       useTicketCache=true;
    

    为了将client.properties 传递给例如kafka-console-consumer 你还需要提供--consumer.config 参数:

    对于 Linux:

    bin/kafka-console-consumer.sh --bootstrap-server localhost:9092 --topic test  --consumer.config client.properties --from-beginning
    

    对于 Windows:

    bin/kafka-console-consumer.bat --bootstrap-server localhost:9092 --topic test --consumer.config client.properties --from-beginning
    

    【讨论】:

    • 谢谢。从 Windows 命令行调用 kafka-console-consumer.bat 时如何传入 client.properties?
    • 再次感谢。我现在遇到了一个不同的错误,但似乎它至少现在正在连接。我收到的错误是“无法登录:正在要求客户端输入密码,但 Kafka 客户端代码当前不支持从用户那里获取密码。无法从用户那里获取身份验证信息”。如果我使用 keytab 文件,我不应该通过提供密码,对吗?
    • @ajtatum 也许最好就新问题提出一个新问题并提供有关 kerberos 配置的更多详细信息。
    • keyTab="..." 在 Windows 上的值应该是多少?只是C:\whatever\path\myfile.keytab?这对我不起作用...我似乎无法让它找到我的密钥表。
    • @PatrickSzalapski 是的。您可以使用C:/whatever/path/myfile.keytabC:\\whatever\\path\\myfile.keytab。他们都应该工作。
    猜你喜欢
    • 2019-09-12
    • 1970-01-01
    • 2015-05-23
    • 2010-11-17
    • 1970-01-01
    • 2011-05-26
    • 1970-01-01
    • 1970-01-01
    • 2015-03-28
    相关资源
    最近更新 更多