天天看点

java apns 推送消息到iphone设备

java代码比较简单,可是使用开源的类库 如https://github.com/notnoop/java-apns

估计卡住的人通常是和apns握手失败。这原因主要是java、.net和mac的ssl连接区别.

java需要把下载的文件再次转换才可以使用。

参考:

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次密码,这里密码都设置为:123456。

openssl pkcs12 -nocerts -out PushChat_Noenc.pem -in PushChat.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

这样我们就得到了在java、或者.net应用程序中使用的证书文件:aps_developer_identity.p12

openssl 命令可以直接在mac终端执行