我的目标是使用我现有的私钥创建 CSR(证书签名请求)以提交给 Apple 以生成新的 iPhone 分发证书。我确保证书是左侧选定的类别。我尝试右键单击我的私钥并单击使用导入的私钥从证书颁发机构请求证书,当我尝试保存它时会收到以下错误。
在钥匙串中找不到指定的项目。
我在浏览文件菜单时也遇到了同样的错误:钥匙串访问 > 证书助手
我从其他互联网来源收集到的是,如果您导入了私钥,钥匙串访问不允许您创建新的 CSR,只有当您从该工具本地创建密钥时。
我最终做的是导出私钥并使用 openssl 生成 Apple 接受的新 CSR,现在引用新导入的私钥。
导出私钥
- 右键单击私钥
- 导出
- 确保选择了 p12 文件格式
- 保存
- 输入密码(可选)
- 允许访问导出密钥
- 打开终端并转到导出目录
- 从 p12 容器中提取密钥
请小心,因为 .pem 私钥不再受密码保护)
$ openssl pkcs12 -in Certificates.p12 -out Certificates.pem -nodes
Enter Import Password: ********************
MAC verified OK
使用导出的私钥创建新的 CSR
$ openssl req -out Certificates.csr -key Certificates.pem -new
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]:.
State or Province Name (full name) [Some-State]:.
Locality Name (eg, city) []:.
Organization Name (eg, company) [Internet Widgits Pty Ltd]:.
Organizational Unit Name (eg, section) []:.
Common Name (e.g. server FQDN or YOUR name) []:John Doe Dev Key
Email Address []:thon@example.com
Please enter the following 'extra' attributes
to be sent with your certificate request
A challenge password []:
An optional company name []:
需要注意的几点:
- 输入 。当您希望该字段为空白时,或者默认值将包括括号 [] 中的任何内容。
- Common Name (CN) 应该是您的私钥名称(例如,John Doe Dev Key)
- 电子邮件地址应该是您的电子邮件地址(例如 thon@example.com)
- 其他所有内容都应为空白
验证您的 CSR
$ openssl req -noout -text -in Certificates.csr
Certificate Request:
Data:
Version: 0 (0x0)
Subject: CN=John Doe Dev Key/emailAddress=thon@example.com
Subject Public Key Info:
Public Key Algorithm: rsaEncryption
RSA Public Key: (2048 bit)
Modulus (2048 bit):
…
Exponent: 65537 (0x10001)
Attributes:
a0:00
Signature Algorithm: sha1WithRSAEncryption
…
您应该关心的是 主题 行,并验证它是否正确。
现在您需要做的就是将其提交给 Apple,等待生成证书,然后安装它。导入新生成的证书后,您会看到它会引用您在上面导出的旧证书。