iOS Push Key 產生步驟

August 25, 2014 0 Comments

雖然弄過很多次了,但只要其中一個小細節弄錯就會失敗,所以還是記一下避免自己忘記.

1. 產生CSR :  鑰匙圈存取 > 憑證輔助程式 > 從憑證授權要求憑證 > 一般名稱記得打比較好記的(如果有太多帳號或APP才方便管理) > 存到磁碟












2. 產生aps_development.cer : MemberCenter > AppIDs > 要用的App > Edit > Push Notifications > 把CSR丟上去 產生aps_development.cer

3. 產生.p12 :回到鑰匙圈 > 鑰匙 > 步驟一產生的憑證 > 選專用密鑰 > 右鍵輸出...

--------------------------------
4. 終端機開始結合:
[先把aps_development.cer 轉成pem]
$ openssl x509 -in aps_development.cer -inform der -out PushCert.pem
[把 p12 也轉成pem]
$ openssl pkcs12 -nocerts -out PushKey.pem -in PushKey.p12

[測試可不可以用]
$ openssl s_client -connect gateway.sandbox.push.apple.com:2195 
-cert PushCert.pem -key PushKey.pem

正常情況會出現:

如果這邊出現error字樣就是有錯誤,就要檢視哪個步驟出了問題.












[將兩個pem 結合給程式用]
$ cat PushCert.pem PushKey.pem > ck.pem

*2016/03/11 update:
Apple have changed the name of the certificate that is issued. You can now use the same certificate for both development and production. While you can still request a development only certificate you can no longer request a production only certificate.

Since the purpose of the certificate is no longer production only Apple has changed the common name to Apple Push Services. The functionality of the certificate is not affected.

0 comments: