在配置 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做相应的调整,如下图。

【java/C# 服务器】IOS 配置推送证书 p12文件流程 - 勿以己悲

这样就OK了。

相关文章:

  • 2021-06-28
  • 2021-12-21
  • 2021-06-21
  • 2022-12-23
  • 2022-01-09
  • 2021-06-20
  • 2021-11-21
猜你喜欢
  • 2022-12-23
  • 2021-12-16
  • 2021-12-29
  • 2021-12-28
  • 2021-04-17
  • 2021-06-25
  • 2021-12-12
相关资源
相似解决方案