Skip to content

Instantly share code, notes, and snippets.

@Austinb
Austinb / keytool_replace.md
Last active February 26, 2020 16:23
Java keytool replace existing certificate

Fast guide for replacing a certificate in a JAVA key store using keytool and openssl. Useful if you do not want to generate a new csr. This also has commands for extracting the private key in case you lost it or do not have access to it.

This guide is probably incomplete but you have to start somewhere...

First backup your existing keystore file. If you break it you have a copy you can fallback on.

cp /path/to/keystore ~/keystore

All the commands will prompt for passwords. Passwords are usually required when dealing with keytool so it is best to set a password when prompted instead of just entering an empty password.