2012-09-13 33 views

回答

2

當你進入發放模板啓用/配置推送通知,它要求的第一件事是CSR(代碼簽名證書)。

您可以使用鑰匙串訪問的現有現有生成此私鑰,而不是創建新私鑰。

只需打開鑰匙串訪問,然後滾動直到找到一個以前的私人密鑰(可能稱爲你的名字),然後右鍵單擊(雙指點擊),然後選擇從證書頒發機構申請證書「bla bla bla「

我只在用戶電子郵件地址和CA電子郵件地址中輸入相同的電子郵件地址,然後選擇「保存到磁盤」。

然後上傳,要

+2

我也與上述相同的建議,但錯誤發生:(「在Keychain中找不到指定的項目。」可能是什麼問題? –

+0

同樣的問題在這裏,但我知道一個事實,我已經在去年的某個時候工作了......所以蘋果在他們的隨機更新中破壞了一些東西..? – Captnwalker1

+1

@ mysticboy59有關此錯誤的詳細信息,請參閱此問題:http://stackoverflow.com/questions/16845169/error-when-trying-to-obtain-a-certificate-the-specified-item-could-not-be-發現 –

26

通常創建.CER文件,您可以通過右鍵單擊在鑰匙串訪問現有的私鑰和從證書頒發機構選擇申請一個證書以「姓名:關鍵「

不幸的是,除非你的在你的鑰匙串中有對應的公鑰,否則這將會失敗,並且「指定的項目不能在鑰匙串中找到」。對此沒有技術上的理由 - 證書籤名請求(CSR)只能從私鑰生成 - 但Keychain Access不理解這一點。

您有兩種選擇。

導出私鑰並生成CSR手動

這是一個快速選項,只會生成一個CSR,你可以上傳到蘋果公司。

  1. 選擇在鑰匙串訪問私鑰,然後單擊文件 - 出口項目...
  2. 將文件以.p12格式保存在某處,但請記住路徑。這些說明假定它位於您的主目錄中,並稱爲exported.p12。將密碼留空。
  3. 打開終端,然後輸入:

    openssl req -new -key <(openssl pkcs12 -in ~/exported.p12 -nocerts -nodes -passin pass:"") > new.certSigningRequest 
    

    [1]在文章的結尾這是怎麼回事的詳細信息。

  4. 按回車爲每個提示(Apple不關心這些值)。完成後,您將有一個.certSigningRequest適合上傳到Apple Developer Portal。下載相關證書時,它將與原始私鑰配對。

  5. 刪除exported.p12文件,因爲它包含私鑰材料。

重新創建公鑰所以鑰匙串訪問是幸福

此選項是一個長期的修復程序會讓你產生從直接從鑰匙串訪問原始密鑰的CSR。這些說明假設您目前不能使用鑰匙串訪問來執行此操作,因爲您錯過了相應的公用密鑰版本。您可以通過轉到鑰匙串訪問中的「鑰匙」類別並查找具有相同名稱的「私鑰」和「公鑰」來檢查此情況。

  1. 選擇在鑰匙串訪問私鑰,然後單擊文件 - 出口項目...
  2. 將文件以.p12格式保存在某處,但請記住路徑。這些說明假定它位於您的主目錄中,並稱爲exported.p12。將密碼留空。
  3. 打開終端,然後輸入:

    openssl pkcs12 -in ~/exported.p12 -nocerts -nodes | openssl rsa -pubout > public.pem 
    

    [2]在文章的結尾這是怎麼回事的詳細信息。

  4. 導入此公鑰到鑰匙串訪問使用security工具:

    security -v import public.pem -k ~/Library/Keychains/login.keychain 
    

    你應該可以看到 「1個鍵導入。」

更改~/Library/Keychains/login.keychain如果您想將其導入到另一個鑰匙串。 (您可以通過訪問編輯 - 鑰匙串列表在鑰匙串訪問中看到每個鑰匙串的居住位置)。

  1. 打開鑰匙串訪問並找到名爲「導入的公鑰」的公鑰。雙擊它並將其名稱更改爲與原始私鑰相同的名稱。
  2. 刪除exported.p12public.pem

現在,您可以用鼠標右鍵單擊原始私鑰,選擇請求從證書頒發機構的證書以「姓名鍵」生成CSR。

說明

[1]該命令,細分:

openssl req -new # Generate a new certificate signing request 
    -key   # Instead of generating a key, use an existing one 
    <(    # Put the output of the following command in a temporary file 
        # (a Bash feature, not specific to OpenSSL) 
    openssl pkcs12 -in ~/exported.p12 # Read keys from the specified PKCS12 file 
    -nocerts   # Don't output the certificate contained in the file 
    -nodes   # Output the private key from the file 
    -passin pass:"" # The password for the container is blank 
) 
> new.certSigningRequest # Write the generated CSR to a file 

[2]第二命令,細分:

openssl pkcs12 -in ~/exported.p12 # Read keys from the specified PKCS12 file 
    -nocerts -nodes     # Output only the private key, no certificates 
| openssl rsa -pubout    # Compute the public key from a private key 
> public.pem      # Write the public key to a file 
+0

很好的答案。很多細節和解釋。正是我需要的。 – Glenn

+0

我在步驟5中遇到了問題:無法重命名在我的自定義鑰匙串中導入的公鑰。我必須將它移動到會話鑰匙串中,重命名它,然後將其移回。 – Julien