首先到蘋果后臺

截屏2023-10-20 14.33.42.png
1.創(chuàng)建好Distribution的.cer,下載后雙擊安裝。
2.再去創(chuàng)建APNs的.cer,下載后雙擊安裝。(否則下載的.cer無法導(dǎo)出為.p12)
3.打開鑰匙串訪問,左側(cè)選擇登錄

截屏2023-10-20 14.39.41.png
右側(cè)選證書
截屏2023-10-20 14.40.10.png

截屏2023-10-20 14.40.10.png
將安裝好的APNs 證書 右鍵導(dǎo)出為.cer 到操作目錄命名:aps.cer ,在次操作導(dǎo)出為.p12文件到操作目錄命名:push.p12。
(導(dǎo)出時彈出的設(shè)置密碼 直接回車 沒有密碼)。
打開終端,cd到操作目錄
執(zhí)行命令-> 生成證書的pem文件
openssl x509 -inform der -in aps.cer -out cer.pem
執(zhí)行命令-> 生成證書的pem文件,這里會要求輸入密碼,直接回車2次
openssl pkcs12 -in push.p12 -out key.pem -nodes
執(zhí)行命令-> 合成pem文件
cat cer.pem key.pem > ck.pem
執(zhí)行命令-> 生成p12
openssl pkcs12 -export -in ck.pem -out pushbird.p12
最后將目錄下的ck.pem 或者 pushbird.p12 發(fā)送給后臺人員,完畢。
附:
服務(wù)器是用php實(shí)現(xiàn)的用pem文件。
服務(wù)器使用java/c#實(shí)現(xiàn)的用p12文件。
開發(fā)環(huán)境驗(yàn)證pem方法
openssl s_client -connect gateway.sandbox.push.apple.com:2195 -cert ck.pem
正式環(huán)境驗(yàn)證pem方法
openssl s_client -connect gateway.push.apple.com:2195 -cert ck.pem
參考作者,致謝。
問題處理
最新報錯

截屏2024-03-27 17.31.49.png
Error outputting keys and certificates
80FB8E5EF87F0000:error:0308010C:digital envelope routines:inner_evp_generic_fetch:unsupported:crypto/evp/evp_fetch.c:355:Global default library context, Algorithm (RC2-40-CBC : 0), Properties ()
在執(zhí)行openssl pkcs12 -in push.p12 -out key.pem -nodes時,終端報錯
問題解決
你的本地openssl版本太高,點(diǎn)擊訪達(dá),前往文件夾
/usr/local/Cellar/