security find-identity 列出了一个身份,但我在 Keychain Access 中找不到该身份

security find-identity lists an identity, but I can't find the identity in Keychain Access

我根据 Apple's instructions:

创建了一个带有 certSigningRequest 文件的 Apple 分发证书

To manually generate a Certificate, you need a Certificate Signing Request (CSR) file from your Mac. To create a CSR file, follow the instructions below to create one using Keychain Access. Create a CSR file.

In the Applications folder on your Mac, open the Utilities folder and launch Keychain Access.

Within the Keychain Access drop down menu, select Keychain Access > Certificate Assistant > Request a Certificate from a Certificate Authority.

In the Certificate Information window, enter the following information:
    In the User Email Address field, enter your email address.
    In the Common Name field, create a name for your private key (e.g., John Doe Dev Key).
    The CA Email Address field should be left empty.
    In the "Request is" group, select the "Saved to disk" option.
Click Continue within Keychain Access to complete the CSR generating process.

我从 Apple 下载了 public 密钥作为 .cer 文件。但是,现在,我在 Keychain Access.app 中找不到证书 + 密钥对。在 login 钥匙串下选择 Certificates Category 时,我希望看到类似我的开发证书 + 密钥对的内容。

我确实看到 Keys 下列出的私钥与我在 .certSigningRequest 中包含的名称相同,但通常我也可以在下面看到证书,如下面的开发证书:

我能够通过命令行找到身份

$ security find-identity
Policy: X.509 Basic
  Matching identities
  1) WWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWW "iPhone Developer: Heath Borders (XXXXXXXXXX)"
  2) YYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYY "iPhone Distribution: Heath Borders (ZZZZZZZZZZ)"
     2 identities found

  Valid identities only
  1) WWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWW "iPhone Developer: Heath Borders (XXXXXXXXXX)"
  2) YYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYY "iPhone Distribution: Heath Borders (ZZZZZZZZZZ)"
     2 identities found

但是如果我在特定的钥匙串中搜索,我找不到它:

$ security list-keychains
    "/Users/hborders/Library/Keychains/login.keychain-db"
    "/Library/Keychains/System.keychain"
$ security find-identity /Users/hborders/Library/Keychains/login.keychain-db
    Policy: X.509 Basic
      Matching identities
      1) WWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWW "iPhone Developer: Heath Borders (XXXXXXXXXX)"
         1 identity found

      Valid identities only
      1) WWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWW "iPhone Developer: Heath Borders (XXXXXXXXXX)"
         1 identity found

$ security find-identity /Users/hborders/Library/Keychains//Library/Keychains/System.keychain
     0 valid identities found

我的证书在哪里?

出于某种原因,当我导入从 Apple 下载的 .cer 文件时,Keychain Access.app 将 public 密钥导入 System 钥匙串并将私钥导入我的 login 钥匙串。因此,仅在 loginSystem 中搜索无法找到身份。只有两者结合才能产生有效身份。

我将 public 钥匙从 System 钥匙串移到了 login 钥匙串中,现在一切正常。