The JKS Converter turns a certificate file (PEM, CRT, DER, PKCS7) or a PKCS12 file (.p12,
.pfx) into a Java keystore (JKS) file with a password of your choice. KafkIO itself doesn't need it: use it
when another Java tool insists on a JKS file.
When you need a JKS
For KafkIO's own connections you don't need to convert anything. The SSL settings of a cluster read JKS, PKCS12 and PEM files directly: pick the matching Truststore type or Keystore type (see Supported certificate and key formats).
The converter is for everything else that talks to the same cluster: the Kafka command-line tools, Kafka Connect workers, your own Java applications and other JVM-based tools whose settings only offer a JKS truststore or keystore. Typical cases:
- your organisation hands out its CA certificate as a
.pemor.crtfile, and a tool needs it as a truststore; - you have a client certificate and private key as a
.p12or.pfxfile (exported from a certificate manager or a browser, for example), and a tool needs it as a keystore for mutual TLS.
Many current Java tools, including Kafka's own clients, also accept PKCS12 directly (for Kafka,
ssl.truststore.type=PKCS12), so check the tool's settings before converting.
Opening the converter
Open it from Tools ▸ JKS Converter 1:
- JKS Converter opens the converter in its own window.
The Want to create a JKS? link above the truststore fields of the cluster dialog (on the Kafka Security and Schema Registry tabs, for example) opens the same window, so you can convert a file in the middle of setting up a cluster.
The converter doesn't block the rest of KafkIO, and it starts empty each time you open it. Choosing Tools ▸ JKS Converter while it's already open brings it to the front (restoring it if it's minimised); the Want to create a JKS? link opens another converter window.
Converting a file
Here a client certificate and its key, in storefront-app.p12, are about to be converted:
- File location: the file to convert. Type or paste its path, or pick it with the folder button. Convert to JKS stays disabled until the field points at a file that exists.
- File type: what the file is (see the table below). It starts at CRT / PEM / X.509.
- Existing key password: the PKCS12 file's password. Only shown for P12 / PFX / PKCS12.
- New store password: the password for the file you're about to create.
- Convert to JKS reads the file, then asks where to save the new one. Your existing file isn't changed.
-
Choose the file and its type
Fill in 1 File location and pick the 2 File type. The type goes by what's inside the file, not its name: a
.crtor.cerfile is usually a certificate, a.pfxis PKCS12. -
Enter the passwords
For a PKCS12 file, its current password in 3; then a password for the new file in 4. See Passwords.
-
Convert and save
Click 5 Convert to JKS. If the file can be read, a save dialog opens in the folder you last used for a file in KafkIO, suggesting the name
jksstore.jks. KafkIO adds.jksto the name if you leave it out, and asks before overwriting a file of that name. When it's written, a notification says how much went in, for example JKS saved with 2 certificates. If the file can't be read, nothing is saved and an error explains why (see When conversion fails).
What each file type converts
| File type | Reads | The new file contains | Use it as |
|---|---|---|---|
| CRT / PEM / X.509 | X.509 certificates: a PEM file with one or more -----BEGIN CERTIFICATE----- blocks
(a CA bundle, say), a binary DER certificate, or a PKCS7 file (.p7b). |
Every certificate in the file, each as a trusted certificate under an alias made from its common
name (CN): lower case, with spaces and other symbols turned into hyphens, so
CN=Storefront Root CA becomes storefront-root-ca. A certificate without a
CN gets cert-1, cert-2 and so on (its position in the file); a name that's
already taken gets -2, -3 added. |
A truststore. |
| P12 / PFX / PKCS12 | A PKCS12 file and everything in it. | Every certificate and every private key with its certificate chain, under the same aliases as in the PKCS12 file. | A keystore (or a truststore, if it only holds certificates). |
.key, or a PEM starting -----BEGIN PRIVATE KEY-----)
can't be converted: package the key and its certificate as PKCS12 first (for example with
openssl pkcs12 -export) and convert that as P12 / PFX / PKCS12. If a
PEM file holds a certificate and its key, the certificate is converted and the key is skipped; the
notification after saving says so.Passwords
- Existing key password
- The password the PKCS12 file was exported with. KafkIO uses it both to open the file and to read the private keys inside, which is how PKCS12 files are normally made (one password for both). Leave it blank if the file has no password. A wrong password stops the conversion (see When conversion fails).
- New store password
- Protects the new file; the tool that uses it needs this password (for Kafka clients,
ssl.truststore.passwordorssl.keystore.password). Private keys copied from a PKCS12 file get the same password, so where a tool also asks for a key password (ssl.key.password), it's this one too. A JKS file always has a password: left blank, it's an empty one. Certificates aren't secret, so a truststore converted from a certificate works with an empty password if your tool allows that; for a keystore with a private key, always set one.
The saved file
The file is a real JKS keystore, the format Java tools mean when they ask for a JKS file or
ssl.truststore.type=JKS. To check what went in, list it with keytool:
keytool -list -keystore jksstore.jks -storepass the-new-store-password
It reports Keystore type: JKS and one line per entry: a trustedCertEntry for each
certificate (under the aliases described above) and a
PrivateKeyEntry for each key copied from a PKCS12 file.
JKS is Java's older, proprietary format; Java itself now prefers PKCS12, and keytool may suggest
migrating when you change a JKS file. That's expected. If the tool you're setting up accepts PKCS12, you can skip
the conversion and give it the PKCS12 file directly.
Using the result
Point the tool at the file and give it the new store password. For the Kafka command-line tools and Java clients, a truststore converted from a CA certificate goes in the client properties like this:
security.protocol=SSL
ssl.truststore.location=/path/to/jksstore.jks
ssl.truststore.password=the-new-store-password
ssl.truststore.type=JKS
and a keystore converted from a client certificate's PKCS12 file adds:
ssl.keystore.location=/path/to/storefront-app.jks
ssl.keystore.password=the-new-store-password
ssl.key.password=the-new-store-password
ssl.keystore.type=JKS
In KafkIO you can use the file too, with type Java KeyStore (JKS), although the original PEM or PKCS12 file works just as well there. See SSL / TLS for where truststores and keystores go in a cluster's settings.
When conversion fails
If KafkIO can't read the file, it shows an error and saves nothing:
The message under Could not convert to JKS file says what the file looks like and what to do. KafkIO checks the file's contents, not its name:
| Message | What to do |
|---|---|
| The Existing key password is wrong for this PKCS12 file (or the file has a password and the field is blank). | Enter the password the PKCS12 file was exported with in Existing key password. |
| This looks like a PKCS12 file. Choose P12 / PFX / PKCS12 as the File type. | The file is PKCS12 (often named .pfx, sometimes .crt): change the
File type. |
| This looks like a certificate, not a PKCS12 file. Choose CRT / PEM / X.509 as the File type. | The other way round: change the File type. |
| This file holds a private key, not a certificate. ... | A key can't be converted on its own: see the note above. |
| This file is a certificate signing request (CSR), not a certificate. ... | A .csr is what you send to get a certificate: convert the certificate you got back. |
| This file is already a Java keystore (JKS), so there's nothing to convert. | Use the file as it is. |
| No certificate was found in this file. / The file is empty. | Check you picked the right file. |
| This file isn't a certificate KafkIO can read (PEM, DER or PKCS7). ... / This file isn't a PKCS12 file KafkIO can read. ... | The file is something else, or damaged. Check the File type, and open the
file in a text editor: a PEM file starts with -----BEGIN. |
| The file couldn't be read. ... | The file was moved or deleted, or you're not allowed to open it. |
A problem writing the file (no permission for the folder, say) shows Could not save JKS file with the file name instead. Show Details has the full error, and View Logs opens KafkIO's logs.