Converting Keystore (JKS) to PEM file

Overview 

Some Python library like kafka-python uses .pem files to connect to Kafka. For this purpose we will have to convert the JKS files to PEM with the help of keytool and openssl commands

This article describes how to generate key and certificate files from keystore in JKS format.

Prerequisites 

Suppose you already has a keystore.jks file following the steps here.

Warning:  Different store and key passwords not supported for PKCS12 KeyStores. We need to keep keystore password and key password the same 

Generate files

The following bash script describes how to generate your key and certificate files from keystore.jks .

Go to the place where you store the keystore.jks, then run this script.
You will get key.pem, CARoot.pem and certificate.pem.

Then you’re good to use these file in your client when connecting to Kafka clusters.

You could find Python examples about how to use these files when connecting to KAFKA MTLS cluster here.

By Instaclustr Support
Need Support?
Experiencing difficulties on the website or console?
Already have an account?
Need help with your cluster?
Contact Support
Why sign up?
To experience the ease of creating and managing clusters via the Instaclustr Console
Spin up a cluster in minutes