ssl - 为什么我可以读取 ksqldb 流而不是 ksql 客户端中的主题?

标签 ssl apache-kafka ksqldb sasl

我正在最新版本(confluent 5.5.1)中的 AWS EC2 实例上测试 ksqldb,并且遇到了我无法解决的访问问题。
我有一个安全的 Kafka 服务器(SASL_SSSL,SASL 模式 PLAIN),一个不安全的模式注册表(Avro 序列化程序的另一个问题,但目前还可以),以及一个安全的 KSQL 服务器和客户端。

  • 主题使用来自 JDBC 源连接器的 AVRO 数据(仅值,无键)正确填充。
  • 我可以毫无问题地使用 ksql 访问 KSQL Server
  • 我可以毫无问题地访问 KSQL REST API
  • 当我在 ksql 中列出主题时,我得到了正确的列表。
  • 当我选择推送流时,我会在将某些内容推送到主题时收到消息(在我的情况下使用 Kafka Connect)。
  • 但是:当我调用“打印主题”时,我会在客户端中收到约 60 秒的 block ,然后是“获取主题元数据时超时已过期”。

  • ksql-kafka.log 因重复条目而变得狂野,例如
    [2020-09-02 18:52:46,246] WARN [Consumer clientId=consumer-2, groupId=null] Bootstrap broker ip-10-1-2-10.eu-central-1.compute.internal:9093 (id: -3 rack: null) disconnected (org.apache.kafka.clients.NetworkClient:1037)
    
    相应的代理日志显示
    Sep  2 18:52:44 ip-10-1-6-11 kafka-server-start: [2020-09-02 18:52:44,704] INFO [SocketServer brokerId=1002] Failed authentication with ip-10-1-2-231.eu-central-1.compute.internal/10.1.2.231 (Unexpected Kafka request of type METADATA during SASL handshake.) (org.apache.kafka.common.network.Selector)
    
    这是我的 ksql-server.properties 文件:
    ksql.service.id= hf_kafka_ksql_001
    bootstrap.servers=ip-10-1-11-229.eu-central-1.compute.internal:9093,ip-10-1-6-11.eu-central-1.compute.internal:9093,ip-10-1-2-10.eu-central-1.compute.internal:9093
    ksql.streams.state.dir=/var/data/ksqldb
    ksql.schema.registry.url=http://ip-10-1-1-22.eu-central-1.compute.internal:8081
    ksql.output.topic.name.prefix=ksql-interactive-
    ksql.internal.topic.replicas=3
    confluent.support.metrics.enable=false
    
    # currently the keystore contains only the ksql server and the certificate chain to the CA
    ssl.keystore.location=/var/kafka-ssl/ksql.keystore.jks
    ssl.keystore.password=kspassword
    ssl.key.password=kspassword
    ssl.client.auth=true
    # Need to set this to empty, otherwise the REST API is not accessible with the client key.
    ssl.endpoint.identification.algorithm=
    
    # currently the truststore contains only the CA certificate
    ssl.truststore.location=/var/kafka-ssl/client.truststore.jks
    ssl.truststore.password=ctpassword
    
    security.protocol=SASL_SSL
    sasl.mechanism=PLAIN
    sasl.jaas.config=org.apache.kafka.common.security.plain.PlainLoginModule required \
        username="ksql" \
        password="ksqlsecret";
    listeners=https://0.0.0.0:8088
    advertised.listener=https://ip-10-1-2-231.eu-central-1.compute.internal:8088
    
    authentication.method=BASIC
    authentication.roles=admin,ksql,cli
    authentication.realm=KsqlServerProps
    
    # authentication for producers, needed for ksql commands like "Create Stream"
    producer.ssl.endpoint.identification.algorithm=HTTPS
    producer.security.protocol=SASL_SSL
    producer.sasl.mechanism=PLAIN
    producer.ssl.truststore.location=/var/kafka-ssl/client.truststore.jks
    producer.ssl.truststore.password=ctpassword
    producer.sasl.mechanism=PLAIN
    producer.sasl.jaas.config=org.apache.kafka.common.security.plain.PlainLoginModule required \
        username="ksql" \
        password="ksqlsecret";
    
    # authentication for consumers, needed for ksql commands like "Create Stream"
    consumer.ssl.endpoint.identification.algorithm=HTTPS
    consumer.security.protocol=SASL_SSL
    consumer.ssl.truststore.location=/var/kafka-ssl/client.truststore.jks
    consumer.ssl.truststore.password=ctpassword
    consumer.sasl.mechanism=PLAIN
    consumer.sasl.jaas.config=org.apache.kafka.common.security.plain.PlainLoginModule required \
        username="ksql" \
        password="ksqlsecret";
    
    
    我用
    ksql --user cli --password test --config-file /var/kafka-ssl/ksql_cli.properties https://ip-10-1-2-231.eu-central-1.compute.internal:8088'
    
    这是我的 ksql 客户端配置 ksql_cli.properties:
    security.protocol=SSL
    #ssl.client.auth=true
    ssl.truststore.location=/var/kafka-ssl/client.truststore.jks
    ssl.truststore.password=ctpassword
    ssl.keystore.location=/var/kafka-ssl/ksql.keystore.jks
    ssl.keystore.password=kspassword
    ssl.key.password=kspassword
    
    JAAS 配置,作为服务启动时的参数包含在内
    KsqlServerProps {
      org.eclipse.jetty.jaas.spi.PropertyFileLoginModule required
      file="/var/kafka-ssl/cli.password"
      debug="false";
    };
    
    cli.password 包含 ksql 客户端的身份验证用户和密码。
    我用
    ksql --user cli --password test --config-file /var/kafka-ssl/ksql_cli.properties https://ip-10-1-2-231.eu-central-1.compute.internal:8088'
    
    我可能尝试过任何键、设置等的排列,但无济于事。显然, key 管理出现了问题。对我来说,使用流是可以的,但低级主题却不行,这令人惊讶。
    有人找到解决该问题的方法了吗?我真的在这里运行 ou 的想法。谢谢。

    最佳答案

    找到了!这很容易被忽视——当然是客户的配置需求。 SASL 设置...

    security.protocol=SASL_SSL
    

    关于ssl - 为什么我可以读取 ksqldb 流而不是 ksql 客户端中的主题?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/63712224/

    相关文章:

    ubuntu - 无法使用 SSL 将 lftp 连接到 IIS FTP

    java - 卡夫卡 : Alter number of partitions for a specific topic using java

    apache-kafka - 卡夫卡 : Messages disappearing from topics, 最大时间=0

    apache-kafka - KSQL : How can I change separator (comma) of DELIMITED FORMAT?

    apache http 重定向到 https 多个重写条件

    http - ruSTLs HTTP 请求响应 301

    iphone - 无法连接到生产 Apple 推送通知服务器

    python - 基于时间戳值流式传输和处理数据(使用 Kafka 和 Spark Streaming)

    apache-kafka - CloudFormation - 如何将 bootsrap 参数添加到 Ksql Server

    apache-kafka - 如何根据连接器名称获取Kafka源连接器架构