简体   繁体   English

我在使用keytool获取SHA1证书时遇到问题

[英]I'm having trouble getting SHA1 certificate with keytool

I'm trying to find the SHA1 hash of my signature key store on macos sierra using the following comand: 我正在尝试使用以下命令在macos sierra上找到我的签名密钥库的SHA1哈希:

keytool -exportcert -alias androiddebugkey -keystore $HOME/.android/debug.keystore -list -v -storepass android

The result looks like below: 结果如下所示:

Alias ​​name: androiddebugkey 别名:androiddebugkey
Date of creation: Oct 25, 2017 创作日期:2017年10月25日
Input Type: PrivateKeyEntry 输入类型:PrivateKeyEntry
Length of certificate chain: 1 证书链长度:1
Certificate [1]: 证书[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) keytool错误:java.util.IllegalFormatConversionException:d!= java.lang.String java.util.IllegalFormatConversionException:d!= java.base.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),java.base / java.util.Formatter.format(Formatter.java:2517),java.base / java.lang.String.format(String.java:2747) )java的java.base / sun.security.tools.keytool.Main.withWeak(Main.java:3151)中的java.base / sun.security.tools.keytool.Main.printX509Cert(Main.java:3182)。在java.base / sun的java.base / sun.security.tools.keytool.Main.doCommands(Main.java:1212)中的base / sun.security.tools.keytool.Main.doPrintEntry(Main.java:1995)。 security.tools.keytool.Main.run(Main.java:397),位于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? 据我所知,该命令正在运行,它不是文件的问题,也不是密码,在我看来java中的一个内部错误,它是否缺少一些java包? I am using Java SDK 9.0.1 我正在使用Java SDK 9.0.1

I found that the problem comes from latest version of Keytool in JDK8.151 and JDK9 . 我发现问题来自JDK8.151JDK9最新版Keytool。 By default keytool use system default language and that seems to do not properly work anymore on some languages (in my case French). 默认情况下, keytool使用系统默认语言,并且似乎在某些语言上不再正常工作(在我的例子中是法语)。

It was enough to force output in english by using the parameter -J-Duser.language=en 使用参数-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/a/47181882/5292951

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM