Convert jks to key file for web server

Cli

Run

1
2
3
4
5
6
7
8
# 1. Convert .jks to .p12 (need password)
keytool -importkeystore -srckeystore your-file.jks -destkeystore new-output.p12 -deststoretype PKCS12

# 2. Extract .pem from .p12 (need password)
openssl pkcs12 -nokeys -in new-output.p12 -out new-output.pem

# 3. Extract unencrypted .key from .p12 (need password)
openssl pkcs12 -nocerts -nodes -in new-output.p12 -out final-output.key

Reference

https://gist.github.com/paulosalgado/d12b069498ac6c8ed0821a066d68605e