Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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

like image 677
Subodh Joshi Avatar asked Feb 22 '17 14:02

Subodh Joshi


People also ask

What is alias in Keytool command?

KeyStore Aliases An alias is specified when you add an entity to the keystore using the -genseckey command to generate a secret key, -genkeypair command to generate a key pair (public and private key) or the -importcert command to add a certificate or certificate chain to the list of trusted certificates.

How do I remove a keystore certificate?

Check the contents of the trust store by entering the following in the command prompt: <JAVA_HOME>\bin\keytool -list -v -keystore truststore -storepass access . Note the alias names of the certificates you want to remove. Enter <JAVA_HOME>\bin\keytool -delete -alias <alias name> -keystore truststore.


1 Answers

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:  
...                                    
like image 175
Tim Menapace Avatar answered Sep 18 '22 14:09

Tim Menapace