【问题标题】:Configuring Kafka in .NET using jaas使用 jaas 在 .NET 中配置 Kafka
【发布时间】:2022-01-07 11:20:50
【问题描述】:

我正在尝试使用 Confluent.Kafka 包连接到 Kafka。但是,我需要使用 jaas 作为身份验证方法。我找不到使用 Confluent.Kafka for .NET 的方法。

编辑:

我收到了以下要连接的数据:

bootstrap.servers=pkc.....cloud:9092
ssl.endpoint.identification.algorithm=https
security.protocol=SASL_SSL
sasl.mechanism=PLAIN
sasl.jaas.config=org.apache.kafka.common.security.plain.PlainLoginModule required username="********" password="*******";

我正在尝试像这样创建连接:

var config = new ProducerConfig
{
    BootstrapServers = "pkc.....cloud:9092",
    SslEndpointIdentificationAlgorithm = SslEndpointIdentificationAlgorithm.Https,
    SecurityProtocol = SecurityProtocol.SaslSsl,
    SaslMechanism = SaslMechanism.Plain,
    //Jaas?***
};

你们知道如何设置我收到的 Jaas 吗?

【问题讨论】:

  • JAAS 是特定于 Java 的。您是在问如何添加 SASL 属性?
  • 嗨@OneCricketeer,我在问题中包含了更多细节。我收到了一个 jaas,我需要在 .net 中以某种方式进行配置
  • sasl.jaas.config 仅适用于 Java 客户端,对于基于 librdkafka 的客户端可以忽略
  • 您可能对这个 Confluent Cloud 示例程序感兴趣 - github.com/confluentinc/confluent-kafka-dotnet/blob/master/…
  • 谢谢@OneCricketeer,我试图添加 jaas 而不仅仅是设置用户名和密码

标签: apache-kafka jaas


【解决方案1】:

正如@OneCricketeer 所说,Jaas 是特定于 Java 的。我需要的只是设置用户名和密码。

最后的代码是这样的:

var config = new ProducerConfig
{
    BootstrapServers = "pkc.....cloud:9092",
    SslEndpointIdentificationAlgorithm = SslEndpointIdentificationAlgorithm.Https,
    SecurityProtocol = SecurityProtocol.SaslSsl,
    SaslMechanism = SaslMechanism.Plain,
    SaslUsername = "******",
    SaslPassword = "*****"
};

【讨论】:

    猜你喜欢
    • 2019-02-18
    • 2023-03-15
    • 1970-01-01
    • 2021-07-21
    • 2018-01-27
    • 2018-11-14
    • 1970-01-01
    • 1970-01-01
    • 2019-07-26
    相关资源
    最近更新 更多