Kafka客户端应用程序暂时出现kerberos身份验证失败

时间:2018-11-20 10:29:14

标签: authentication apache-kafka kerberos jaas

我正在使用最新版本的kafka,并在通过SASL_PLAINTEXT将我的消费者/生产者(控制台)客户连接到kafka经纪人时暂时遇到问题。

这是我的jaas配置文件

KafkaClient {
   com.sun.security.auth.module.Krb5LoginModule required
   useTicketCache=true;
};

这是我传递的java属性:

-Djavax.security.auth.useSubjectCredsOnly=false
-Dsecurity.protocol=SASL_PLAINTEXT
-Dsasl.kerberos.service.name=HTTP
-Dsasl.mechanism=GSSAPI

这是我得到的例外:

Caused by: org.apache.kafka.common.KafkaException: javax.security.auth.login.LoginException: Could not login: the client is being asked for a password, but the Kafka client code does not currently support obtaining a password from the user. not available to garner  authentication information from the user
        at org.apache.kafka.common.network.SaslChannelBuilder.configure(SaslChannelBuilder.java:127)
        at org.apache.kafka.common.network.ChannelBuilders.create(ChannelBuilders.java:140)
        at org.apache.kafka.common.network.ChannelBuilders.clientChannelBuilder(ChannelBuilders.java:65)
        at org.apache.kafka.clients.ClientUtils.createChannelBuilder(ClientUtils.java:88)
        at org.apache.kafka.clients.consumer.KafkaConsumer.<init>(KafkaConsumer.java:710)
        ... 33 more
Caused by: javax.security.auth.login.LoginException: Could not login: the client is being asked for a password, but the Kafka client code does not currently support obtaining a password from the user. not available to garner  authentication information from the user
        at com.sun.security.auth.module.Krb5LoginModule.promptForPass(Krb5LoginModule.java:940)

有人可以在这里帮忙吗?

2 个答案:

答案 0 :(得分:0)

jaas文件中缺少

主要和密钥表。

请参阅https://kafka.apache.org/documentation/#security_sasl_kerberos

答案 1 :(得分:0)

我想建议您一些选择,

  1. 在当前兑现的密钥表中列出所有原理,并检查它们是否正确。

  2. 如果尝试使用除KAFKA以外的任何原理对主题进行任何更改,则该操作将失败。设置-Dsasl.kerberos.service.name = kafka

  3. 尝试设置

    export KAFKA_OPTS="-Djava.security.auth.login.config=/path/to/jaas.conf -Djava.security.krb5.conf=/etc/krb5.conf -Dsun.security.krb5.debug=true"

  4. 如果使用控制台生产者/消费者,则需要提供生产者配置/消费者配置。在producer.properties或Consumer.properties中配置以下属性。

    security.protocol=SASL_PLAINTEXT (or SASL_SSL) sasl.mechanism=GSSAPI (or PLAIN)

    对控制台使用者使用以下命令

    kafka-console-consumer --bootstrap-server host:9092 --consumer.config /path/to/consumer.properties --topic Topic

希望这会有所帮助:)