admin管理员组

文章数量:1122846

I'm trying to connect my application with kafka and getting the following error. I'm generating truststore and keystore in the entrypoint.sh following manner.

Truststore:
keytool -keystore "${TRUSTSTORE_JKS_PATH}" -storepass "${KAFKA_TRUSTSTORE_PASSWORD}" -alias CA -importcert -file /tmp/ca.crt -noprompt
keytool -keystore "${TRUSTSTORE_JKS_PATH}" -storepass "${KAFKA_TRUSTSTORE_PASSWORD}" -alias Root -importcert -file /tmp/root.crt -noprompt

openssl pkcs12 -export -in /tmp/user.crt -inkey /tmp/user.key -name "${HOSTNAME}" -password pass:"${KAFKA_KEYSTORE_PASSWORD}" -out "${KEYSTORE_P12_PATH}"

keytool -importkeystore -srckeystore "${KEYSTORE_P12_PATH}" -srcstoretype pkcs12 -srcalias "${HOSTNAME}" -destkeystore "${KEYSTORE_JKS_PATH}" -deststoretype jks -deststorepass "${KAFKA_KEYSTORE_PASSWORD}" -destalias "${HOSTNAME}" -srcstorepass "${KAFKA_KEYSTORE_PASSWORD}"
Props : {default.value.serde=org.apache.kafkamon.serialization.Serdes$StringSerde, ssl.keystore.location=/app/keystore.jks, bootstrap.servers=devserve:9094, key.serializer=class org.apache.kafkamon.serialization.StringSerializer, default.key.serde=org.apache.kafkamon.serialization.Serdes$StringSerde, security.protocol=SSL, ssl.truststore.location=/app/truststore.jks, value.serializer=class com.fasterxml.jackson.databind.JsonSerializer, ssl.keystore.password=password, ssl.truststore.password=password, application.id=configurable-app, ssl.endpoint.identification.algorithm=}
Error:
Caused by: org.apache.kafkamon.errors.SslAuthenticationException: SSL handshake failed
Caused by: javax.ssl.SSLHandshakeException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
    at java.base/sun.security.ssl.Alert.createSSLException(Alert.java:131)
    at java.base/sun.security.ssl.TransportContext.fatal(TransportContext.java:383)
    at java.base/sun.security.ssl.TransportContext.fatal(TransportContext.java:326)
    at java.base/sun.security.ssl.TransportContext.fatal(TransportContext.java:321)
    at 

How to resolve this issue?

本文标签: opensslKafka SSL handshake failed in Java applicationStack Overflow