[英]OSX Keychain Access-Generate CSR from existing Private Key for APNS (Apple Push Notification Service)
當您需要為APNS創建新證書時,Provisioning Portal“向導”始終提供創建新CSR的步驟,這意味着您還需要創建新的公鑰/私鑰。 這些可能會開始失控,那么有沒有辦法在現有私鑰的Keychain Access中創建CSR(代碼簽名請求),而不是每次都要創建一個新的?
謝謝
通常,您可以通過右鍵單擊Keychain Access中的現有私鑰並選擇使用“密鑰名稱”從證書頒發機構申請證書來執行此操作。
不幸的是,除非你的鑰匙串中還有相應的公鑰,否則這將失敗,並且“在Keychain中找不到指定的項目”。 這沒有技術上的原因 - 證書簽名請求(CSR)只能從私鑰生成 - 但Keychain Access不理解這一點。
你有兩個選擇。
這是一個快速選項,只會生成一個可以上傳到Apple的CSR。
.p12
格式,但請記住該路徑。 這些說明假定它位於您的主目錄中並稱為exported.p12
。 將密碼留空。 打開終端並輸入:
openssl req -new -key <(openssl pkcs12 -in ~/exported.p12 -nocerts -nodes -passin pass:"") > new.certSigningRequest
有關正在發生的事情的詳細信息,請參閱本文末尾的[1] 。
按Enter鍵進行每個提示(Apple不關心這些值)。 完成后,您將獲得適合上傳到Apple Developer Portal的.certSigningRequest
。 下載相關證書時,它將與原始私鑰配對。
exported.p12
文件,因為它包含私鑰材料。 此選項是一個長期修復程序,可讓您直接從Keychain Access生成原始密鑰的CSR。 這些說明假設您目前無法使用Keychain Access這樣做,因為您錯過了私鑰的相應公共版本。 您可以通過轉到Keychain Access中的“Keys”類別並查找具有相同名稱的“私鑰”和“公鑰”來檢查這一點。
.p12
格式,但請記住該路徑。 這些說明假定它位於您的主目錄中並稱為exported.p12
。 將密碼留空。 打開終端並輸入:
openssl pkcs12 -in ~/exported.p12 -nocerts -nodes | openssl rsa -pubout > public.pem
有關正在發生的事情的詳細信息,請參閱本文末尾的[2] 。
使用security
工具將此公鑰導入Keychain Access:
security -v import public.pem -k ~/Library/Keychains/login.keychain
你應該看到“1鍵導入”。
如果要將其導入另一個鑰匙串,請更改~/Library/Keychains/login.keychain
。 (您可以通過轉到密鑰鏈訪問中的編輯 - 鑰匙串列表來查看每個鑰匙串的生活位置)。
exported.p12
和public.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
當您進入配置配置文件以啟用/配置推送通知時,它首先要求的是CSR(代碼簽名證書)。
您可以使用Keychain Access中的現有私鑰生成此密鑰,而不是創建新密鑰。
只需打開鑰匙串訪問,然后滾動直到找到以前的私鑰(可能稱為您的名字),然后右鍵單擊(兩個手指點擊),然后選擇從證書頒發機構申請證書“bla bla bla” 。
我只需在用戶電子郵件地址和CA電子郵件地址中輸入相同的電子郵件地址,然后選擇保存到磁盤。
然后上傳它以創建.cer文件
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.