【问题标题】:How do i create the key and crt file from given code signing file cer only?如何仅从给定的代码签名文件 cer 创建密钥和 crt 文件?
【发布时间】:2014-08-15 16:17:12
【问题描述】:

我有代码签名证书,从他们那里我只得到了一个X.cer 文件。
当我需要签署我的 .exe 时,我需要一个 PFX 文件,我需要两个文件 A.key 和 B.crt

问。我如何从 X.cer 文件、A.key 和 B.crt 制作?这样我就可以开始第 1 步了?

第 1 步:

$ openssl pkcs12 -inkey A.key -in B.crt -export -out GOAL.pfx

第 2 步:

signtool sign /debug /f GOAL.pfx /p MyPassword MyFile.exe

or

signtool sign /debug /n "My Company Certificate" MyFile.exe

编辑:仍然困惑如何制作那个 A.key 文件?

openssl pkcs12 -export -in X.cer -inkey A.key -out GOAL.pfx -certfile ??.cer

or

openssl pkcs12 -export -in X.cer -inkey A.key -out GOAL.pfx

-in 指定输入证书嵌入输出文件(代码签名官方文件)

-inkey 指定您使用 OpenSSL 生成的密钥文件(??????? 如何 ?????)

-out 告诉 openssl 你想要的输出文件名称(PFX 文件)

-certfile 用于指定要添加到输出 pfx 文件的附加证书(可以忽略)可选。

【问题讨论】:

  • Adding an intermediate certificates to a pkcs12 file 的可能重复项。该问题提供的答案将引导您完成从签名证书、私钥和中间证书创建 PFX 文件的所有步骤。
  • 抱歉,您分享的链接没有说明如何获取该 A.key 文件?这里问的不是重复的问题。购买 Code sign 后,我现在只有一个名为 CER 的文件,我需要准备其余所有令人困惑的文件,并且所有答案都没有得到准确解释。
  • 你应该有钥匙。您使用它来生成请求。你在哪个平台上工作?这是否适用于 Windows 应用商店生态系统(Microsoft 保留了您的私钥,这意味着它已经被泄露)?
  • Linux 和 Mac 平台。我不知道我曾经用于购买 CODE Signing 的 KEY 文件。我从来没有为代码签名上传密钥文件。我只有一个名为 CER 的文件,在我的示例中,我将其命名为 X.cer,除此之外我没有 A.key 和 B.crt
  • 我正在准备的 PFX 文件是为 Windows 7 准备的。我通常每天使用 Linux 和 Mac。

标签: openssl certificate ssl-certificate code-signing pfx


【解决方案1】:

注意:许多专家完全相信并忽略了“您没有密钥文件”,请注意这是正常的,许多供应商不要求提供他们自己制作的密钥文件并提供 PFX 或仅限 CER 文件。结果它变得令人困惑,就像我的情况一样。

1) 创建 A.key

$ openssl req -out CSR.csr -new -newkey rsa:2048 -nodes -keyout privateKey.key
Generating a 2048 bit RSA private key
...............+++
....................+++
writing new private key to 'privateKey.key'
-----
You are about to be asked to enter information that will be incorporated
into your certificate request.
What you are about to enter is what is called a Distinguished Name or a DN.
There are quite a few fields but you can leave some blank
For some fields there will be a default value,
If you enter '.', the field will be left blank.
-----
Country Name (2 letter code) [AU]:BE
State or Province Name (full name) [Some-State]:Oost-Vlanderen
Locality Name (eg, city) []:Dendermonde
Organization Name (eg, company) [Internet Widgits Pty Ltd]:TEST
Organizational Unit Name (eg, section) []:IT
Common Name (e.g. server FQDN or YOUR name) []:NAME of DEVLOPER
Email Address []:email@domain.com

Please enter the following 'extra' attributes
to be sent with your certificate request
A challenge password []:
An optional company name []:

$ ls
CSR.csr     privateKey.key

2) 要让 B.crt 重命名 X.cer

3) 最后应用

openssl pkcs12 -export -in X.cer -inkey A.key -out GOAL.pfx

编辑: 终于完成了,我还没有 KEY 文件。供应商给了我 PFX 文件

C:\Program Files (x86)\Windows Kits\8.0\bin\x86>signtool.exe sign /debug /f C:\Users\sun\Downloads\s.pfx /p 1234password C:\Users\sun\Downloads\IeAddOnDemo\IeAddOnDemo\bin\Debug\IeAddOnDemo.dll

The following certificates were considered:
    Issued to: xxxxN.V./S.A.
    Issued by: GlobalSign CodeSigning CA - SHA256 - G2
    Expires:   Wed Apr 08 18:13:59 2015
    SHA1 hash: xxxxx

    Issued to: GlobalSign CodeSigning CA - SHA256 - G2
    Issued by: GlobalSign
    Expires:   Fri Aug 02 12:00:00 2019
    SHA1 hash: xxxxxx

After EKU filter, 2 certs were left.
After expiry filter, 2 certs were left.
After Private Key filter, 1 certs were left.
The following certificate was selected:
    Issued to: xxxN.V./S.A.
    Issued by: GlobalSign CodeSigning CA - SHA256 - G2
    Expires:   Wed Apr 08 18:13:59 2015
    SHA1 hash: xxx


The following additional certificates will be attached:
    Issued to: GlobalSign CodeSigning CA - SHA256 - G2
    Issued by: GlobalSign
    Expires:   Fri Aug 02 12:00:00 2019
    SHA1 hash: xxxx

Done Adding Additional Store
Successfully signed: C:\Users\sun\Downloads\IeAddOnDemo\IeAddOnDemo\bin\Debug\IeAddOnDemo.dll

Number of files successfully Signed: 1
Number of warnings: 0
Number of errors: 0

【讨论】:

  • ... 但是您从 CA 取回的签名证书不适用于您刚刚生成的密钥。您不能只为正在使用的任意公钥或证书生成私钥。
  • 在这种情况下我该怎么办?因为我从来没有钥匙,也没有被要求给他们钥匙。他们只是给我发了一份证书,它只是一个 CER 文件。
  • 解决这个问题。我已重新发出证书请求,导致证书颁发者无效。我已要求向我发送 PFX 文件格式。他们正在努力。请注意,许多供应商不会从我们这里获取 KEY 文件,它们都是自己生成的。
  • @jwww:请看我的详细回答,最后它的工作。我正在寻找答案,就像我在详细模式下所做的那样。
  • 我想我不太明白你有什么或你想做什么。从私钥和证书创建 PFX 文件并不难。从 PFX 文件中提取私钥也不难。未能理解您的需求,我深表歉意。
猜你喜欢
  • 2016-06-23
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2017-08-04
  • 1970-01-01
  • 2012-06-28
  • 1970-01-01
相关资源
最近更新 更多