Skip to content

Instantly share code, notes, and snippets.

@abdul-sami
Last active June 24, 2024 08:11
Show Gist options
  • Save abdul-sami/87b7cdc831b8fb986ac1 to your computer and use it in GitHub Desktop.
Save abdul-sami/87b7cdc831b8fb986ac1 to your computer and use it in GitHub Desktop.
Export a Public Key Certificate from Java Key Store to Base 64 (PEM) Format
#Method One: Using both Keytool and Openssl
keytool -export -keystore <keystore.jks> -alias <aliasName> -file publiccert.cer
openssl x509 -inform der -in publiccert.cer -out publiccert.pem
#Method Two: Direct conversion with only keytool (thanks to http://stackoverflow.com/a/6076689/552148)
keytool -exportcert -alias <selfsigned> -keystore <test-user.jks> -rfc -file <test-user.pem>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment