24

I have imported multiple certificates(with alias name) into pc.keystore. I want to delete 2 aliases (mydomain and ourdomain) entries from the keystore.

I know we can delete one entry from keystore using alias like:

keytool -delete -alias mydomain -keystore pc.keystore

But i want to delete two aliases (mydomain and ourdomain) entries from pc.keystore. Is there any option to achieve this ?

Thanks in advance.

jww
  • 97,681
  • 90
  • 411
  • 885
Mohan
  • 351
  • 1
  • 2
  • 4

3 Answers3

52

Is there a reason you can't do this?

keytool -delete -alias mydomain -keystore pc.keystore
keytool -delete -alias ourdomain -keystore pc.keystore
vikingsteve
  • 38,481
  • 23
  • 112
  • 156
  • yes we can do but before delete i have to check the key store are exit or not – Mohan May 22 '13 at 10:56
  • what do you mean "check the ks are exit or not" ? – vikingsteve May 22 '13 at 10:58
  • is there any option to check both in one command because in my case 2 alias may vary in future. it may increase so its better to have in one command. – Mohan May 22 '13 at 11:08
  • To avoid password prompt use the following, but beware that your pass will be stored in the bash_history which is insecure: keytool -delete -noprompt -alias mydomain -keystore pc.keystore -storepass xxx – ibai Apr 01 '17 at 01:57
5

It can be done in one command as well:

keytool -delete -alias mydomain -alias ourdomain -keystore pc.keystore
vikingsteve
  • 38,481
  • 23
  • 112
  • 156
ALi Maken
  • 137
  • 2
  • 2
  • 2
    Sorry but I tried this and it didn't work. What happens is that `ourdomain` will be deleted but `mydomain` will stay. Refer to documentation: https://docs.oracle.com/javase/8/docs/technotes/tools/unix/keytool.html#keytool_option_delete – vikingsteve Oct 16 '15 at 12:58
2
keytool -delete -alias  name_of_certificate -keystore "C:\Program Files\Java\jdk1.8.0_192\jre\lib\security\cacerts" -storepass changeit
Girdhar Singh Rathore
  • 5,030
  • 7
  • 49
  • 67
  • 1
    Consider adding some explanation along with your code. – L. F. Jun 10 '19 at 10:01
  • 1
    command is self explainatory where name_of_certificate is the alias name that you want to delete from yout keystore and after -keystore the path is path to your jks/keystore place – Nitin Jain Apr 06 '22 at 21:29