gpt4 book ai didi

node.js - 如何传递 SSL 配置,如信任库位置和密码?

转载 作者:太空宇宙 更新时间:2023-11-03 13:59:52 32 4
gpt4 key购买 nike

现在我已经使用自签名证书配置了我的 Kafka 服务器。

version: '2'
services:
zookeeper:
image: wurstmeister/zookeeper:latest
ports:
- 2181:2181
hostname: zookeeper
kafka:
image: wurstmeister/kafka:2.11-2.0.0
command: [start-kafka.sh]
ports:
- 9093:9093
hostname: kafka
environment:
KAFKA_LISTENERS: SSL://0.0.0.0:9093
KAFKA_ADVERTISED_LISTENERS: SSL://alfrescokafka.leafycode.com:9093
KAFKA_SSL_KEYSTORE_LOCATION: /home/amur42s/ssl/kafka.server.keystore.jks
KAFKA_SSL_KEYSTORE_PASSWORD: oE4KJ9FVMjMXGpgpp0qwLzUDy0uz
KAFKA_SSL_KEY_PASSWORD: oE4KJ9FVMjMXGpgpp0qwLzUDy0uz
KAFKA_SSL_TRUSTSTORE_LOCATION: /home/amur42s/ssl/kafka.server.truststore.jks
KAFKA_SSL_TRUSTSTORE_PASSWORD: 123
KAFKA_ADVERTISED_HOST_NAME: 116.203.65.132 # docker-machine ip
KAFKA_ZOOKEEPER_CONNECT: "zookeeper:2181"
KAFKA_CREATE_TOPICS: ""
KAFKA_SSL_CLIENT_AUTH: 'required'
KAFKA_SECURITY_INTER_BROKER_PROTOCOL: 'SSL'
volumes:
- /var/run/docker.sock:/var/run/docker.sock
- /home/ssl:/home/ssl
depends_on:
- "zookeeper"

不幸的是,我无法使用 Kafka-node TimeoutError: Request timed out after 30000ms 连接到它。看来我需要设置 ssl.truststore.locationssl.truststore.password。我该怎么做?

export const kafkaClientOptions = {
kafkaHost: process.env.KAFKA_PRODUCER_HOST,
ssl: true,
sslOptions: {
rejectUnauthorized: false
}
};

const client = new kafka.KafkaClient(kafkaClientOptions);

const Producer = kafka.Producer;
const producer = new Producer(client);

最佳答案

你不应该因为 SSL 错误配置而出现超时错误,但这里是使用 SSL 设置 Kafka 客户端的配置

ssl:true,
sslOptions: {
key: fileManager.readFile("path/to/key"),
cert: fileManager.readFile("path/to/cert"),
ca: fileManager.readFile("path/to/ca"),
passphrase: "your_passphrase"
}

关于node.js - 如何传递 SSL 配置,如信任库位置和密码?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54568935/

32 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com