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

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

Related

Missing keystore - Can't get SHA1

I try to get SHA1 to use for Firebase but I can't get SHA1
In JavaVirtualMachines I using jdk1.8.0_202.jdk
I tried get in gradle -> Task -> Android -> signingReport
=> Error: Missing keystore
I tried get on command line ->
keytool -exportcert -alias androiddebugkey -keystore
~/.android/debug.keystore -list -v
keytool -list -v -keystore /Users/bobhope/.android/debug.keystore -alias androiddebugkey -storepass android -keypass android
=> Error:
keytool error: java.lang.Exception: Keystore file does not exist: /Users/bobhope/.android/debug.keystore
java.lang.Exception: Keystore file does not exist: /Users/bobhope/.android/debug.keystore
at sun.security.tools.keytool.Main.doCommands(Main.java:786)
at sun.security.tools.keytool.Main.run(Main.java:382)
at sun.security.tools.keytool.Main.main(Main.java:375)
Use complete path
Mac:
keytool -list -v -keystore /Users/username/.android/debug.keystore
-alias androiddebugkey -storepass android -keypass android
Linux:
keytool -list -v -keystore /home/username/.android/debug.keystore
-alias androiddebugkey -storepass android -keypass android
Windows:
keytool -list -v -keystore C:\Users\username\.android\debug.keystore
-alias androiddebugkey -storepass android -keypass android
you missed the path in your command
keytool -list -v -alias androiddebugkey -keystore%USERPROFILE%\.android\debug.keystore
after the keystore you should add the path like C:\Users\Username\Downloads
Try these steps:
Clean and rebuild your application.
Open the Gradle tab and go to app -> Tasks -> android
Double click on signingReport.
You will get the required signing report below in the run tab.

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

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

how to delete 2 alias entries from keystore?

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

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!