【java/C# 伺服器】IOS 配置推送認證 p12檔案流程

來源:互聯網
上載者:User

標籤:style   blog   http   java   color   使用   

在配置 P12 認證檔案之前, 我們要準備三個檔案

 

1、PushChat.certSigningRequest      請求認證檔案

2、PushChatKey.p12                       請求認證檔案後, 在認證秘鑰中產生了一個公開金鑰和私密金鑰, 通過私密金鑰匯出的p12檔案

3、aps_developer_identity.cer          使用請求認證檔案 產生的  推送認證

  

 擷取到的deviceToken,我們可以通過webservice服務提交給.net應用程式,這裡我簡單處理,直接列印出來,拷貝到.net應用環境中使用。

    發送通知的.net應用程式出來需要知道deviceToken之外,還需要一個與APNS串連的認證。

    這個認證可以通過我們前面產生的兩個檔案中得到。

 

具體配置操作:

 

使用OpenSSL

1、將aps_developer_identity.cer轉換成 aps_developer_identity.pem格式。

openssl x509 -in aps_developer_identity.cer -inform DER -out aps_developer_identity.pem -outform PEM

2、將p12格式的私密金鑰轉換成pem,需要設定4次密碼,密碼都設定為:abc123。

openssl pkcs12 -nocerts -out PushChat_Noenc.pem -in PushChatKey.p12

3、用certificate和the key 建立PKCS#12格式的檔案。

openssl pkcs12 -export -in aps_developer_identity.pem -inkey PushChat_Noenc.pem -certfile PushChat.certSigningRequest -name "aps_developer_identity" -out aps_developer_identity.p12

這樣我們就得到了在.net應用程式中使用的認證檔案:aps_developer_identity.p12。

 

 

 

在.net應用程式中發送通知。

有個開源的類庫:apns-sharp。

地址是:http://code.google.com/p/apns-sharp/。

我們下載原始碼,對裡面的JdSoft.Apple.Apns.Notifications做相應的調整就能用了。

我們根據DeviceToken和p12File對JdSoft.Apple.Apns.Notifications.Test做相應的調整,如。

這樣就OK了。

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.