一.前期準(zhǔn)備
1.打開鑰匙串訪問,創(chuàng)建.certSigningRequest

創(chuàng)建certSigningRequest.png
2.填寫certSigningRequest信息

配置certSigningRequest.png
3.完成后在鑰匙串中默認(rèn)會生成跟以上信息一樣的秘鑰,找到并導(dǎo)出專用秘鑰

導(dǎo)出秘鑰.png
4.登錄蘋果官網(wǎng)配置帶push的證書,下載備用
5.現(xiàn)在有兩個需要的文件官網(wǎng)配置的aps.cer, 導(dǎo)出的私鑰panda_kesimeishi@kesibp.com.p12
6.打開終端,使用openssl對以上兩個文件進(jìn)行加密,文件名使用對應(yīng)的路徑
(1)加密aps.cer
openssl x509 -in aps.cer -inform der -out aps.pem
(2) 加密私鑰
openssl pkcs12 -nocerts -in private.p12 -out key.pem
注意:第一次輸入的密碼是導(dǎo)出p12文件時輸入的密碼,之后的密碼隨便設(shè)置成一樣的即可,比如sdfe1234e
(3) 合并加密文件
a.PHP服務(wù)端
cat aps.pem key.pem > push.pem
b. java服務(wù)端
openssl pkcs12 -export -in aps.pem -inkey key.pem -out push.p12
7.測試ApplePushServer正常:
telnet gateway.sandbox.push.apple.com 2195
它將嘗試發(fā)送一個規(guī)則的,不加密的連接到APNS服務(wù)。如果你看到下面的反饋,那說明你的MAC能夠到達(dá)APNS。按下Ctrl+C關(guān)閉連接。如果得到一個錯誤信息,那么你需要確保你的防火墻允許2195端口。
dailiangjinmac-mini:hd ice$ telnet gateway.sandbox.push.apple.com 2195
Trying 17.110.226.164...
Connected to gateway.sandbox.push-apple.com.akadns.net.
Escape character is '^]'.
~~~
#####8.測試加密證書工作正常:
openssl s_client -connect gateway.sandbox.push.apple.com:2195 -cert aps.pem -key key.pem