Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Convert p12 to jks (letsencrypt)
#!/bin/bash
certdir=/etc/ssl/private
keystore_path=/etc/letsencrypt/archive/example.com/keystore1.jks
letsdir=/etc/letsencrypt/archive/example.com
password=yourpasswordhere
for i in {6..1}; do cp $letsdir/keystore$i.jks $letsdir/keystore$((i+1)).jks; done
keytool -delete -alias root -storepass $password -keystore $keystore_path
keytool -delete -alias 1 -storepass $password -keystore $keystore_path
keytool -importkeystore -srcstorepass $password -deststorepass $password -destkeypass $password -srckeystore $certdir/cert.p12 -srcstoretype PKCS12 -alias 1 -keystore $keystore_path
keytool -import -trustcacerts -alias root -deststorepass $password -file $certdir/chain.pem -noprompt -keystore $keystore_path
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.