作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在尝试使用 openssl 和 keytool 命令为 Kafka 配置 SSL。
我将证书配置为接受特定的 CN 和一些替代名称;这是我所做的:
openssl req -x509 -nodes -newkey rsa:2048 -days 3650 -sha256 -keyout ca-key -out ca-cert -reqexts SAN -extensions SAN -subj '/CN=kafkabroker' -config <(cat /etc/ssl/openssl.cnf; printf "[SAN]\nsubjectAltName=DNS:kafkabroker,DNS:kafka-broker,DNS:localhost,DNS:host.docker.internal,IP:127.0.0.1,IP:1.1.1.1, IP:2.2.2.2")
keytool -keystore kafka.server.keystore.jks -alias kafkabroker -validity 365 -genkey -storepass passw -keypass passw -ext SAN=DNS:kafkabroker,DNS:localhost,IP:1.1.1.1,DNS:juliet,DNS:host.docker.internal,IP:2.2.2.2,IP:127.0.0.1
keytool -keystore kafka.client.truststore.jks -alias CARoot -import -file ca-cert
keytool -keystore kafka.server.keystore.jks -alias kafkabroker -certreq -file cert-file
openssl x509 -req -CA ca-cert -CAkey ca-key -in cert-file -out cert-signed -days 3650 -CAcreateserial -passin pass:passw
keytool -keystore kafka.server.keystore.jks -alias CARoot -import -file ca-cert
keytool -keystore kafka.server.keystore.jks -alias kafkabroker -import -file cert-signed
keytool -keystore kafka.client.keystore.jks -alias kafkabroker -validity 365 -genkey -storepass passw -keypass passw -ext SAN=DNS:kafkabroker,DNS:localhost,IP:1.1.1.1,DNS:juliet,DNS:host.docker.internal,IP:2.2.2.2,IP:127.0.0.1
keytool -keystore kafka.client.keystore.jks -alias kafkabroker -certreq -file cert-file
openssl x509 -req -CA ca-cert -CAkey ca-key -in cert-file -out cert-signed -days 3650 -CAcreateserial -passin pass:passw
keytool -keystore kafka.client.keystore.jks -alias CARoot -import -file ca-cert
keytool -keystore kafka.client.keystore.jks -alias kafkabroker -import -file cert-signed
keytool -keystore kafka.server.truststore.jks -alias CARoot -import -file ca-cert
java.security.cert.CertificateException: No subject alternative names present
最佳答案
主要问题是,kafka 在签名的 SERVER 证书(位于 server.keystore.jks 中)中需要 SAN。如我所见,在您的请求部分中,您没有添加 SAN 名称:
openssl x509 -req -CA ca-cert -CAkey ca-key -in cert-file -out cert-signed -days 3650 -CAcreateserial -passin pass:passw -extfile openssl-sign.cnf -extensions server_cert
[ server_cert ]
# Extensions for server certificates (`man x509v3_config`).
basicConstraints = CA:FALSE
nsCertType = server
nsComment = "Openssl Server generated Certificate"
subjectKeyIdentifier = hash
authorityKeyIdentifier = keyid,issuer:always
keyUsage = critical, digitalSignature, keyEncipherment
extendedKeyUsage = serverAuth,clientAuth
subjectAltName = DNS:kafkabroker,DNS:localhost,IP:1.1.1.1,DNS:juliet,DNS:host.docker.internal,IP:2.2.2.2,IP:127.0.0.1
openssl req -text -noout -verify -in cert-file
openssl x509 -text -noout -in cert-signed
关于ssl - X509 SSL : No name matching <hostname> found,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52403898/
我是一名优秀的程序员,十分优秀!