- 目的 : 一切都為了簡化 APNS 憑證,建立的問題,因 php/python 需用 .pem 來與 APNS 進行驗證,故利用簡易的 tool 透過 openssl 將 .p12 -> .pem,並達到基本測試效果
- 可與 apnsReceiver 聯合測試
- 接收訊息
- 判斷此 token 是哪一種憑證建立,並對應到適當的 pem,進行發送
- openssl 1.0.1 or later :
openssl version
- curl support http2 :
curl -V
- 收納憑證
- 建立憑證
- 測試憑證
- Apple Push Notification service SSL (Sandbox)
- Apple Push Notification service SSL (Sandbox & Production) : 新的 production 的 apns cer 包含 Sandbox & Production
- 測試 apns server
- 測試推播 : 要求安裝 curl with http2
- install(mac) :
brew install curl --with-nghttp2
brew link curl --force
- install(mac) :
- 專案環境建立,可參考 /drawer/sample 檔案內容
- 開啟 cmd,執行
sh main.sh
- 選擇 (1) : Create 'PEM'
- 輸入專案名稱
- 輸入 dev 或 pro
sh main.sh
- 選擇 2(dev) or 3(pro)
- 若錯誤,則會產生錯誤訊息
- ex : 憑證錯誤,無法跟伺服器產生交握 =>
unable to load client certificate private key file
orunable to load certificate
- ex : 將 dev 的憑證,丟給 api.push.apple.com:443 => 錯誤訊息
{"reason":"BadCertificateEnvironment"}
- ex : 憑證錯誤,無法跟伺服器產生交握 =>
- 若正確,則最後只會出現
?@@DONE
- 根據分類的專案,來進行 pem 憑證的建立
- 根據 sandbox pem 的建立後,進行 openssl 的測試連接
- 根據 production pem 的建立後,進行 openssl 的測試連接
- Test your computer to connect APNS, the channel is working
- If you don't know how to create 'APNS certificate', check out!(website)
- Troubleshooting Push Notifications(website)
- 產生 curl 測試 push 指令
- required : https://curl.haxx.se/docs/http2.html
- install(mac) :
brew install curl --with-nghttp2
brew link curl --force
- develop.cer : from develop center, download SSL Certificate file from Push Notifications
- developKey.p12 : from keychain
openssl x509 -in [develop].cer -inform der -out [cer].pem
openssl pkcs12 -nocerts -out [key].pem -in [developKey].p12
cat [cer].pem [key].pem > [final].pem