java 我在使用 keytool 获取 SHA1 证书时遇到问题
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/46958548/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
I'm having trouble getting SHA1 certificate with keytool
提问by Jeilson Araujo
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
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)
别名 ?? 名称:androiddebugkey
创建日期:2017 年 10 月 25 日
输入类型:PrivateKeyEntry
证书链长度:1
证书 [1]:
keytool 错误: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) 在 java.base/java.util.Formatter$FormatSpecifier.printInteger(Formatter.java:2846) 在 java.base/java.util.Formatter$FormatSpecifier.print(Formatter.java:2800) 在 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) ) 在 java.base/sun.security.tools.keytool.Main.withWeak(Main.java:3151) 在 java.base/sun.security.tools.keytool.Main.printX509Cert(Main.java:3182) 在 java。 java 中的 base/sun.security.tools.keytool.Main.doPrintEntry(Main.java:1995)。base/sun.security.tools.keytool.Main.doCommands(Main.java:1212) 在 java.base/sun.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? I am using Java SDK 9.0.1
就我所见,该命令正在运行,这不是文件问题,也不是密码问题,在我看来是 java 内部错误,是否缺少一些 java 包?我正在使用 Java SDK 9.0.1
回答by gbaccetta
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).
我发现问题来自于JDK8.151
和 中最新版本的 Keytool JDK9
。默认情况下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