ibm-messaging / kafka-java-vertx-starter

Starter Java app for testing connection to Apache Kafka with Vert.x
Apache License 2.0
44 stars 32 forks source link

Event Stream starter application failed to load SSL keystore truststore.p12 due to "parseAlgParameters failed: ObjectIdentifier() -- data isn't an object ID (tag = 48)" error #239

Open falixchong opened 2 years ago

falixchong commented 2 years ago

Bug

Issue Summary

Trying out CP4I Event Stream starter application. Been getting parseAlgParameters failed: ObjectIdentifier() -- data isn't an object ID (tag = 48) error when running demo-all.jar with the generated properties from the starter application.

Access event stream starter application via Toolbox -> Starter Application -> Get Started

Environment

How To Reproduce This Issue

  1. Download the JAR You'll need to go to GitHub and download the latest JAR for the starter application. https://github.com/ibm-messaging/kafka-java-vertx-starter/releases

  2. Generate properties file, then download and unzip Download and unzip the file which will contain a properties file (containing credentials and configuration) and the certificates the application requires to connect to your chosen Event Streams topic.

  3. Navigate to the JAR file downloaded from GitHub, and run it Run the following command replacing with the full filepath to the kafka.properties file and certificates downloaded in step 2

java -Dproperties_path=<path-to-properties> -jar demo-all.jar

Expected Behaviour

Application started in X ms

Relevant Logs


2021-12-23 23:19:34,769 INFO [vert.x-eventloop-thread-0] kafka.vertx.demo.Main - Application version: 1.1.3
2021-12-23 23:19:35,152 INFO [vert.x-eventloop-thread-2] kafka.vertx.demo.WebSocketServer - 🚀 WebSocketServer started
2021-12-23 23:19:35,240 ERROR [vert.x-eventloop-thread-1] io.vertx.core.impl.ContextImpl - Unhandled exception
org.apache.kafka.common.KafkaException: Failed to construct kafka producer
    at org.apache.kafka.clients.producer.KafkaProducer.<init>(KafkaProducer.java:441)
    at org.apache.kafka.clients.producer.KafkaProducer.<init>(KafkaProducer.java:273)
    at io.vertx.kafka.client.producer.KafkaWriteStream.create(KafkaWriteStream.java:103)
    at io.vertx.kafka.client.producer.KafkaProducer.create(KafkaProducer.java:192)
    at kafka.vertx.demo.PeriodicProducer.setup(PeriodicProducer.java:42)
    at kafka.vertx.demo.PeriodicProducer.lambda$start$0(PeriodicProducer.java:32)
    at io.vertx.core.impl.future.FutureImpl$1.onSuccess(FutureImpl.java:91)
    at io.vertx.core.impl.future.FutureImpl$ListenerArray.onSuccess(FutureImpl.java:262)
    at io.vertx.core.impl.future.FutureBase.emitSuccess(FutureBase.java:60)
    at io.vertx.core.impl.future.FutureImpl.tryComplete(FutureImpl.java:211)
    at io.vertx.core.impl.future.Composition$1.onSuccess(Composition.java:62)
    at io.vertx.core.impl.future.FutureImpl$ListenerArray.onSuccess(FutureImpl.java:262)
    at io.vertx.core.impl.future.FutureBase.emitSuccess(FutureBase.java:60)
    at io.vertx.core.impl.future.FutureImpl.tryComplete(FutureImpl.java:211)
    at io.vertx.core.impl.future.Mapping.onSuccess(Mapping.java:40)
    at io.vertx.core.impl.future.FutureBase.emitSuccess(FutureBase.java:60)
    at io.vertx.core.impl.future.FutureImpl.tryComplete(FutureImpl.java:211)
    at io.vertx.core.impl.future.Mapping.onSuccess(Mapping.java:40)
    at io.vertx.core.impl.future.FutureBase.emitSuccess(FutureBase.java:60)
    at io.vertx.core.impl.future.FutureImpl.tryComplete(FutureImpl.java:211)
    at io.vertx.core.impl.future.CompositeFutureImpl.trySucceed(CompositeFutureImpl.java:163)
    at io.vertx.core.impl.future.CompositeFutureImpl.lambda$all$0(CompositeFutureImpl.java:38)
    at io.vertx.core.impl.future.FutureImpl$3.onSuccess(FutureImpl.java:141)
    at io.vertx.core.impl.future.FutureBase.emitSuccess(FutureBase.java:60)
    at io.vertx.core.impl.future.FutureImpl.tryComplete(FutureImpl.java:211)
    at io.vertx.core.impl.future.Composition$1.onSuccess(Composition.java:62)
    at io.vertx.core.impl.future.FutureBase.emitSuccess(FutureBase.java:60)
    at io.vertx.core.impl.future.SucceededFuture.addListener(SucceededFuture.java:88)
    at io.vertx.core.impl.future.Composition.onSuccess(Composition.java:43)
    at io.vertx.core.impl.future.FutureBase.emitSuccess(FutureBase.java:60)
    at io.vertx.core.impl.future.FutureImpl.tryComplete(FutureImpl.java:211)
    at io.vertx.core.impl.future.Composition$1.onSuccess(Composition.java:62)
    at io.vertx.core.impl.future.FutureImpl$ListenerArray.onSuccess(FutureImpl.java:262)
    at io.vertx.core.impl.future.FutureBase.lambda$emitSuccess$0(FutureBase.java:54)
    at io.netty.util.concurrent.AbstractEventExecutor.safeExecute(AbstractEventExecutor.java:164)
    at io.netty.util.concurrent.SingleThreadEventExecutor.runAllTasks(SingleThreadEventExecutor.java:469)
    at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:500)
    at io.netty.util.concurrent.SingleThreadEventExecutor$4.run(SingleThreadEventExecutor.java:986)
    at io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74)
    at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30)
    at java.lang.Thread.run(Thread.java:748)
Caused by: org.apache.kafka.common.KafkaException: org.apache.kafka.common.KafkaException: Failed to load SSL keystore /Users/falix/Desktop/es-client1.1.3/test-es_properties/truststore.p12 of type PKCS12
    at org.apache.kafka.common.network.SaslChannelBuilder.configure(SaslChannelBuilder.java:172)
    at org.apache.kafka.common.network.ChannelBuilders.create(ChannelBuilders.java:157)
    at org.apache.kafka.common.network.ChannelBuilders.clientChannelBuilder(ChannelBuilders.java:73)
    at org.apache.kafka.clients.ClientUtils.createChannelBuilder(ClientUtils.java:105)
    at org.apache.kafka.clients.producer.KafkaProducer.newSender(KafkaProducer.java:449)
    at org.apache.kafka.clients.producer.KafkaProducer.<init>(KafkaProducer.java:430)
    ... 40 common frames omitted
Caused by: org.apache.kafka.common.KafkaException: Failed to load SSL keystore /Users/falix/Desktop/es-client1.1.3/test-es_properties/truststore.p12 of type PKCS12
    at org.apache.kafka.common.security.ssl.DefaultSslEngineFactory$SecurityStore.load(DefaultSslEngineFactory.java:306)
    at org.apache.kafka.common.security.ssl.DefaultSslEngineFactory$SecurityStore.<init>(DefaultSslEngineFactory.java:285)
    at org.apache.kafka.common.security.ssl.DefaultSslEngineFactory.createTruststore(DefaultSslEngineFactory.java:264)
    at org.apache.kafka.common.security.ssl.DefaultSslEngineFactory.configure(DefaultSslEngineFactory.java:144)
    at org.apache.kafka.common.security.ssl.SslFactory.instantiateSslEngineFactory(SslFactory.java:136)
    at org.apache.kafka.common.security.ssl.SslFactory.configure(SslFactory.java:93)
    at org.apache.kafka.common.network.SaslChannelBuilder.configure(SaslChannelBuilder.java:168)
    ... 45 common frames omitted
Caused by: java.io.IOException: parseAlgParameters failed: ObjectIdentifier() -- data isn't an object ID (tag = 48)
    at sun.security.pkcs12.PKCS12KeyStore.parseAlgParameters(PKCS12KeyStore.java:819)
    at sun.security.pkcs12.PKCS12KeyStore.engineLoad(PKCS12KeyStore.java:2027)
    at java.security.KeyStore.load(KeyStore.java:1445)
    at org.apache.kafka.common.security.ssl.DefaultSslEngineFactory$SecurityStore.load(DefaultSslEngineFactory.java:303)
    ... 51 common frames omitted
Caused by: java.io.IOException: ObjectIdentifier() -- data isn't an object ID (tag = 48)
    at sun.security.util.ObjectIdentifier.<init>(ObjectIdentifier.java:285)
    at sun.security.util.DerInputStream.getOID(DerInputStream.java:320)
    at com.sun.crypto.provider.PBES2Parameters.engineInit(PBES2Parameters.java:267)
    at java.security.AlgorithmParameters.init(AlgorithmParameters.java:293)
    at sun.security.pkcs12.PKCS12KeyStore.parseAlgParameters(PKCS12KeyStore.java:815)
    ... 54 common frames omitted```
falixchong commented 2 years ago

apparently it was cause by java run time version

java jdk version
openjdk version "1.8.0_282"
OpenJDK Runtime Environment (build 1.8.0_282-bre_2021_01_20_16_06-b00)
OpenJDK 64-Bit Server VM (build 25.282-b00, mixed mode)

I updated my java minor version from 1.8.0_282 to 1.8.0_312 and it works as intended. image (1)