KeyTool error : java.lang.Exception : Alias does not exist

↘锁芯ラ 提交于 2020-12-30 06:00:18

问题


I have sucessfully imported the certificate by below command:

keytool -import -alias "alias-name" -file 
  "C:\somepath\Certificate\portal.cer 
  -keystore C:\Program Files\Java\jdk1.7.0_79\jre\lib\cacerts"

Now I am trying to delete the imported certificate with

keytool -delete -alias "alias-name" -keystore 
     "C:\Program Files\Java\jdk1.7.0_79\jre\lib\cacerts" -storepass changeit

But I am end with the below error message:

KeyTool error : java.lang.Exception : Alias does not exist


回答1:


Check if the alias exists. You can list all entries using:

keytool -list -keystore "C:\Program Files\Java\jdk1.7.0_79\jre\lib\cacerts" -storepass changeit

This command will show all existing aliases in the file. If it's not there, that's why you can't delete it.




回答2:


For Ubuntu / Linux
List all entries from your keystore with the respective alias

keytool -list -v -keystore "myKeyStore.jks" -storepass myPassword

The verbose option '-v' is important, in order to see the aliases

Example output:

Keystore type: PKCS12
Keystore provider: SUN

Your keystore contains 2 entries

Alias name: 1
Creation date: Dec 4, 2019
Entry type: PrivateKeyEntry
Certificate chain length: 2
Certificate[1]:
Owner: CN=yourname.com, O=Your Name, C=XX
Issuer: CN=Issuer CA, O=Issuer Name, C=XX
Serial number: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Valid from: Mon Feb 25 10:04:56 GMT 2019 until: Wed Feb 24 10:04:56 GMT 2021
Certificate fingerprints:
   SHA1: 9F:35:31:B1:A9:C2:37:8D:61:2F:9B:ED:82:3F:45:26:E1:D9:18:83
   SHA256: 34:65:C8:B6:4D:24:9D:20:3C:24:7B:B7:7B:F5:6B:F3:BE:79:11:BE:4F:8C:21:D2:9E:86:CC:AD:17:84:01:C4                                                        
Signature algorithm name: SHA256withRSA
Subject Public Key Algorithm: 2048-bit RSA key
Version: 3
Extensions:  
...                                    


来源:https://stackoverflow.com/questions/42394260/keytool-error-java-lang-exception-alias-does-not-exist

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!