iOS 服务器端推送证书p12文件制作

A、苹果服务器地址:

Productiondevelopment用的push的服器不同
p
dev
是:$apnsHost = 'gateway.sandbox.push.apple.com';
pro
是:$apnsHost = 'gateway.push.apple.com';

所以可以在终端中可以直接进行测试是否网络连通:(终端命令)

telnet gateway.sandbox.push.apple.com 2195
 
telnet gateway.push.apple.com 2195
 
所以在服务器开发时需要注意不同部署时,需要连接不同的服务器;
 
B、p12文件制作(dev和pro 相同)

在配置 P12 证书文件之前, 我们要准备三个文件

1、PushChat.certSigningRequest      请求证书文件

2、PushChatKey.p12                       请求证书文件后, 在证书秘钥中生成了一个公钥和私钥, 通过私钥导出的p12文件 

3、aps_developer_identity.cer          使用请求证书文件 生成的  推送证书  (app中下载下来的)

具体配置操作:

使用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。(pro时候我用英文密码时候,服务器端老是没发用,后来我就改成了全数字)

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

//配置完成之后可以自己初步测算pem文件

//验证证书
 
//开发

openssl s_client -connect gateway.sandbox.push.apple.com:2195 -cert   aps_developer_identity.pem -key  Push_Noenc.pem

 //生产

openssl s_client -connect gateway.push.apple.com:2195 -cert  aps_production.pem -key  Push_Noenc.pem

原文地址:https://www.cnblogs.com/kingbo/p/4309491.html