Languages
[Edit]
EN

*.jks file (Java KeyStore repository) to apache2 *.key and *.crt conversion

6 points
Created by:
Huzaifa-Ball
475

In this article we would like to show how to convert *.jks file (Java KeyStore repository) to apache2 *.key file (with private RSA key) and *.crt file (with certificate).

Note: in below examples password / pass phrase were set to my_secret_password to simplyfy examples.

To make conversion do following steps:

1. convert *.jks file to *.p12 archive file

Edit

Use following command:

Where: keystore.jks and keystore.p12 should be replaced with own names of files if it is necessary.

Output:

Where:

  • Enter destination keystore password: and Re-enter new password: required to type new password for created *.p12 file,
  • Enter source keystore password: requred to type password for *.jks that was source file,
  • my_key was alias that describes stored private key and certificate.

2. convert *.p12 file to *.pem file

Edit

Use following command:

Output:

Where:

  • Enter Import Password: requred to type password for *.p12 that was source file,
  • Enter PEM pass phrase: and Verifying - Enter PEM pass phrase: required to type new password for created *.pem file,

3. split *.pem file to *.key and *.crt files

Edit

It is necessary to do it manually.

We have keystore.pem that we want to split to private.key and certificate.crt files.

keystore.pem looks following way:

We want to create:

private.key file with content:

- certificate.crt file with content:

4. convert private.key from ENCRYPTED PRIVATE KEY format to RSA PRIVATE KEY format

Edit

Use following command:

Where: private.key should be replaced with own names of files if it is necessary.

Output:

Where:

  • Enter pass phrase for private.key: requred to type password for *.key that was source file.

Now private.key file content should look like:

5. apache2 VirtualHost configuration

Edit

Now we can use private.key and certificate.crt to configure VirtualHost.

Note: read this or this article to know more about below examples.

Example HTTPS configuration:

Example HTTP2 / h2 proxy configuration:

1
Donate to Dirask
Our content is created by volunteers - like Wikipedia. If you think, the things we do are good, donate us. Thanks!
Join to our subscribers to be up to date with content, news and offers.
Native Advertising
🚀
Get your tech brand or product in front of software developers.
For more information Contact us
Dirask - we help you to
solve coding problems.
Ask question.

❤️💻 🙂

Join