问题
I'm trying to find the SHA1 hash of my signature key store on macos sierra using the following comand:
keytool -exportcert -alias androiddebugkey -keystore $HOME/.android/debug.keystore -list -v -storepass android
The result looks like below:
Alias name: androiddebugkey
Date of creation: Oct 25, 2017
Input Type: PrivateKeyEntry
Length of certificate chain: 1
Certificate [1]:
keytool error: java.util.IllegalFormatConversionException: d != java.lang.String java.util.IllegalFormatConversionException: d != java.lang.String at java.base/java.util.Formatter$FormatSpecifier.failConversion(Formatter.java:4331) at java.base/java.util.Formatter$FormatSpecifier.printInteger(Formatter.java:2846) at java.base/java.util.Formatter$FormatSpecifier.print(Formatter.java:2800) at java.base/java.util.Formatter.format(Formatter.java:2581) at java.base/java.util.Formatter.format(Formatter.java:2517) at java.base/java.lang.String.format(String.java:2747) at java.base/sun.security.tools.keytool.Main.withWeak(Main.java:3151) at java.base/sun.security.tools.keytool.Main.printX509Cert(Main.java:3182) at java.base/sun.security.tools.keytool.Main.doPrintEntry(Main.java:1995) at java.base/sun.security.tools.keytool.Main.doCommands(Main.java:1212) at java.base/sun.security.tools.keytool.Main.run(Main.java:397) at java.base/sun.security.tools.keytool.Main.main(Main.java:390)
As far as I can see the command is working, it is not a problem with the file nor with password, it seems to me an internal error in java, is it missing some java package? I am using Java SDK 9.0.1
回答1:
I found that the problem comes from latest version of Keytool in JDK8.151
and JDK9
. By default keytool
use system default language and that seems to do not properly work anymore on some languages (in my case French).
It was enough to force output in english by using the parameter -J-Duser.language=en
So try using this command line instead:
keytool -J-Duser.language=en -exportcert -alias androiddebugkey -keystore $HOME/.android/debug.keystore -list -v -storepass android
See also my answer here: https://stackoverflow.com/a/47181882/5292951
来源:https://stackoverflow.com/questions/46958548/im-having-trouble-getting-sha1-certificate-with-keytool