I'm having trouble getting SHA1 certificate with keytool

让人想犯罪 __ 提交于 2019-12-30 02:43:12

问题


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

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