how to delete 2 alias entries from keystore? - keytool

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.

Is there a reason you can't do this?
keytool -delete -alias mydomain -keystore pc.keystore
keytool -delete -alias ourdomain -keystore pc.keystore

It can be done in one command as well:
keytool -delete -alias mydomain -alias ourdomain -keystore pc.keystore

keytool -delete -alias name_of_certificate -keystore "C:\Program Files\Java\jdk1.8.0_192\jre\lib\security\cacerts" -storepass changeit

Related

Warning: use -cacerts option to access cacerts keystore

I am adding a cert to the Java keystore and I get the following warning. The command is successful.
keytool -import -trustcacerts -keystore /usr/lib/jvm/java-11-openjdk-amd64/lib/security/cacerts -storepass changeit -noprompt -alias my_root_ca.pem -file /usr/share/ca-certificates/foo/my_root_ca.pem
The warning is:
Warning: use -cacerts option to access cacerts keystore
How do I get rid of this warning?
Thanks
It's quite easy. If you check keytool manual you can see the following:
$ keytool -importcert -help
keytool -importcert [OPTION]...
Imports a certificate or a certificate chain
Options:
... removed for clearity
-cacerts access the cacerts keystore
To get rid of that warning you must use -cacerts option instead of calling cacert keystore:
keytool -import -trustcacerts -cacerts -storepass changeit -noprompt -alias my_root_ca.pem -file /usr/share/ca-certificates/foo/my_root_ca.pem

keytool error: java.lang.Exception: Only one command is allowed: both -exportcert and -list were specified

Book-Pro:main vy$ keytool -exportcert -list -v \
> -alias androiddebugkey -keystore ~/.android/debug.keystore
keytool error: java.lang.Exception: Only one command is allowed: both
-exportcert and -list were specified.
I am trying to create a SHA1 on MBP for an android Firebase project.
I pull the command from the Firebase console as described...
https://developers.google.com/android/guides/client-auth
keytool -exportcert -list -v \
-alias androiddebugkey -keystore ~/.android/debug.keystore
and I get an error.
keytool error: java.lang.Exception: Only one command is allowed: both
-exportcert and -list were specified.
I have tried hand typing this thinking that perhaps there is a problem with the browser. I installed new JDK... not sure what is going wrong here. assistance please
I sort of fixed it... but Id still like comments.
For Linux / UNIX:
keytool -list -v -alias androiddebugkey -keystore ~/.android/debug.keystore
For Windows:
keytool -list -v -alias androiddebugkey -keystore %USERPROFILE%/.android/debug.keystore
observe I removed the -exportcert part and I did get a sha1 back
for release key this one solved my problem
keytool -list -v -keystore C:\Users\MG\Desktop\test.jks -alias test
For the following command worked.
keytool -keystore C:\Users\hp\.android\debug.keystore -list -v

Is there a way to make keytool not prompt for password for the key?

I am trying to generate a keystore. I have set a password for the keystore but I am trying to not set a password for the key.
keytool -storepass "$password" -keystore ${PFX_broker}server.keystore.jks -alias $brokerCertAlias -validity $validity -genkey -dname "CN=$CN" -noprompt;
The above command will prompt me for a key password which defaults to the store pass when I press enter.
Is it possible to skip setting a password for the key altogether and not have a prompt?
There are parameters to specify key and store passwords
-keypass <your-pass> and -storepass <your-pass>
E.g.
keytool -storepass pass123 -keypass pass123 -keystore keystore.jks -alias myalias -validity 99 -genkey -noprompt
keytool reference
I know this is an old question but I'm facing the same issue and adding -keypass password and because I have a store source too, I'm adding -srcstorepass password for me works. Try this:
keytool -storepass "$password" -keystore ${PFX_broker}server.keystore.jks -alias $brokerCertAlias -validity $validity -genkey -dname "CN=$CN" -noprompt -keypass "$password" -srcstorepass "$password"
But might be different in your case.
It seems keytool always requires a password for both the store and the key. There is no way around it.

Changing a .keystore password

I have the following steps:
1) Open Terminal and cd to where your .keystore is located
2) keytool -storepasswd -new NEWPASSWORD -keystore YOURKEYSTORE.keystore
3) enter your current password
My question is instead of doing step 3, how can I do it with a keytool command?
Thanks.
You could do with -storepass
keytool -storepasswd -new {NEW_PASSWORD} -keystore {KEYSTORE.keystore} -storepass {OLD_PASSWORD}
Close but not quite, eventually I figured out that the password should be changed in two locations, keypasswd & storepasswd:
1) keytool -storepass XXX -keypasswd -keypass XXXXX -new XXXX -keystore "c:\temp\XXXX.keystore" -alias XXX
2) keytool -storepass XXX -storepasswd -new XXXX -keystore "c:\temp\XXX.keystore" -alias XXX

Why can't I get a my MD5 Fingerprint of the SDK Debug Certificate?

I enter the following in the command prompt:
keytool -list -alias androiddebugkey \
-keystore keytool -list -alias androiddebugkey \
-keystore C:\Users\kmmr12.android\debug.keystore \
-storepass android -keypass android \
-storepass android -keypass android
when I press enter I get:
-keystore is not recognized as an internal or external command, operable program or batch file.
Why is that?
Well, you can find an answer, for instance here.
As far as I can tell you're using the right tool but you're adding backslashes ( \ ) which might be causing your trouble.
Try writing the command without the backslashes (for instance
keytool -list -alias androiddebugkey -keystore keytool -list -alias androiddebugkey -keystore C:\Users\kmmr12.android\debug.keystore -storepass android -keypass android -storepass android -keypass android
)
Ok, I believe you are using windows and that's why you get the message.
You should first go find your keytool (usually located at C:\Program Files (x86)\Java\jre7\bin)
Then add it to your windows path by going to System>Advanced System Settings>Environmental Variables. When you go there find the Path from the system variable lists, double click on it, add a ';' to the end of it and paste the location of your keytool folder.
Now you should be able to use the command keytool in windows!