java - jar 签名者 "Only one alias can be specified"3

标签 java code-signing keystore keytool jarsigner

我仔细阅读了问题13335419 , 8748089 , 4282405 ,以及其他一些。他们指出最可能的原因是嵌入空间。另一个答案是可能的证书问题。我用过this tutorial作为指导。

我颁发了真实的证书,而不是像问题中那样的 self 证书。我还使用最新的 JDK,1.8.0-60(64 位)。我卸载了所有其他 JDK。

计算机:

OS: Windows 7 64-bit
JDK Path: "C:\Program Files\Java\jdk1.8.0_60"

我尝试了多种技术来消除空间问题。从管理命令提示符处:

  1. mklink/D C:\Documents\JDK "C:\Program Files\Java\jdk1.8.0_60"
  2. mklink/J C:\Documents\JDK1 "C:\Program Files\Java\jdk1.8.0_60"
  3. mkdir C:\Documents\JDK2(后跟)copy "C:\Program 文件\Java\jdk1.8.0_60"C:\Documents\JDK2

命令行:

jarsigner.exe –keypass <key password> -keystore C:\SoftDev\JavaWorkspaces\myproject\Versions\Current64\mykeystore.keystore –storepass <store password> -tsa http://timestamp.comodoca.com/rfc3161 -digestalg SHA2 C:\SoftDev\JavaWorkspaces\myproject\Versions\Current64\build\bin\myproject.jar 31843016-4ab3-11e5-9ba9-0015170bee96

我通过查看证书详细信息验证了我的证书使用算法 SHA-2 (SHA-256)。当我将证书导出到 PFX 文件时,我尝试了复选框 1(包括路径中的所有证书)和复选框 3(扩展属性)的两种排列。我一开始选择导出私钥。

我与 key 颁发者交谈,他们认为别名应该是 39 个字符,但是我重新检查了发出该命令的命令,经过多次尝试,我得到了 37 个字符。

keytool.exe -importkeystore -srckeystore "C:\Documents\Signing\mypfx.pfx" -srcstoretype pkcs12 -destkeystore C:\SoftDev\JavaWorkspaces\myproject\Versions\Current64\mykeystore.keystore -deststoretype JKS

我使用提到的各种排列输入了上面指定的所有可执行文件(单独在上面列举的各个目录中并指定了完整路径。我尝试指定带引号和不带引号的所有文件名。

KSoftware 给我回信:

I think the problem is that you're somehow specifying too many arguments to jarsigner.exe or one of the arguments is invalid somehow. My knowledge of Java and Jarsigner are limited but I do notice that the alias you're using seems to be of a different format than ones I've seen before (it appears to be too short by a few characters). Did you get that alias string from Step 4, and is that the entire string?

当我对命令执行 -help 时,这些参数与教程相符并且有意义。 我无法解释别名长度和格式差异。 我被告知要使用 JDK 的“绝对最新版本”,我就是(1.8.0-60)。我提到了版本,他们对此表示同意。 步骤 3 和 4 显示相同的别名。也许当时编写教程的人从以不同方式计算别名的 JDK 版本中获取了别名 le-e76649fec-3a2f-4cda-8a6e-441c224481b,而只是教程没有更新。 Comodo 是一家大公司,因此如果教程页面源自他们或者 KSoftware 最近没有进行练习,那么教程页面可能会被他们忽视。不过,从我收集的信息来看,这些步骤似乎是合理的。

更新:

根据我与 EJP 的对话,this question似乎适合签名者的链问题。

Comodo/KSoftware 的回复: 正如我的评论中提到的,@Omikron 对于最初的问题是正确的。错误是从 KSoftware.net 网站进行复制/粘贴。

还有另外 2 个问题。 2. Oracle/Java工具链不支持SHA-256(SHA2),仅支持SHA1。

  • 即使您在订单上注明 SHA-128 (SHA-1),Comodo 也会发出 SHA-256。他们向我表示,他们将停止/停止发行 SHA-128。
  • 签名者的链错误是由 SHA2 引起的。以下是他们对我的回复:

    I understand your hesitation but I assure you I've dealt with the 'chain not validated' problem a lot these days, and it's all related to the SHA-256 move. I can fix that, though, just follow those instructions I sent and we'll get you squared away... I'm still a bit baffled as to why Jarsigner isn't letting you pass that password in on the command line but that's more or less secondary at this point. We can still get you signing JAR files almost immediately with a re-issue from a different root.

    FWIW, the move to SHA-256 and the new RSA roots needed has been a total mess with Java because they are extra, extra slow in adding trusted roots in. This move has been known for a few years now and the latest JDK release is the first that addressed it, and even it didn't address it very well. The best bet for right now is to use an older trusted root already recognized (which is still valid until 2020).

    为了让我的 jar 签名,我正在处理多个问题。

    最后更新 我从 Comodo 收到了新 key ,并且没有任何问题地签署了我的 jar。

    误解:我的原始证书和新证书都是 SHA-256。区别在于CA。原来的一种是“COMODO RSA Code Signing CA”,而新的一种是“COMODO SHA-256 Code Signing CA”。两者的详细 View 显示完全相同的算法。问题确实是KSOftware所说的。 RSA CA 尚未更新其端。

    最佳答案

    命令行中“keypass”和“storepass”之前的字符都是“破折号”(ASCII 代码 0x96,参见https://en.wikipedia.org/wiki/Dash)。它们应该是“连字符减号”(ASCII 代码 0x2D)。

    这可以通过在十六进制编辑器中查看字符串来检查(例如 HxD ):

    enter image description here

    由于字符错误,“-keypass”不会被 jarsigner 识别为参数,这会弄乱整个命令,从而导致奇怪的错误消息。

    类似问题:Certificate chain not found, but keystore contains private key

    关于java - jar 签名者 "Only one alias can be specified"3,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32215051/

    相关文章:

    java - hibernate 恩弗斯 : is it possible to truncate the the Aud table based on date

    ios - 供应配置文件不包括应用程序标识符和钥匙串(keychain)访问组权利

    ios - 启用位码的已辞职应用程序在启动时崩溃

    xcode - Xcode 4 中未显示用于代码签名的自签名证书

    JAVA,SSLSocket 连接问题

    java - 使用 Java 的远程 PC 名称和 IP

    java - 在从 java.util.date 转换为 java.sql.date 之前检查空日期

    java - 如何使用 JavaFX 中的时间轴更新标签的文本?

    java - Android KeyStore问题,另一个设备相同的应用程序

    Android keystore 文件丢失