How to delete already import certificate/alias by keytool command?

It seems you didn’t write the full keystore path. The command should be like this:

keytool -delete -noprompt -alias "initcert" -keystore "C:\Path\to\your\keystore\keycloak.jks"

About the last error, as other pointed out, “cacerts” is different keystore than your keycloak where you have already imported your certificate. You can check if your alias is in there by using the following command:

keytool -list -keystore "C:\Program Files\Java\jdk1.8.0_152\jre\lib\security\cacerts"

And to delete it:

keytool -delete -noprompt -trustcacerts -alias "initcert" -keystore "C:\Program Files\Java\jdk1.8.0_152\jre\lib\security\cacerts"

Then, if you import again the certificate, the error would not appear.

Finally, one last thing, if there is an error like this

keytool error: java.io.FileNotFoundException: C:\Path\to\your\keystore\keycloak.jks (Permission denied)

You should execute the command window in Administrator mode.

Leave a Comment