苹果服务器地址:
production和development用的push的服务器不同
dev是:$apnsHost = ‘gateway.sandbox.push.apple.com’;
pro是:$apnsHost = ‘gateway.push.apple.com’;
p12文件制作(dev和pro 相同)
在配置 P12 证书文件之前, 我们要准备三个文件
1、CertificateSigningRequest.certSigningRequest 请求证书文件
2、aps.cer 使用请求证书文件创建的Sandbox & Production证书
3、push.p12 导入aps.cer后,右击导出p12文件
具体配置操作:(这里演示Sandbox & Production共用证书的创建)
使用OpenSSL
1、aps.cer导出aps.pem。
$ openssl x509 -in aps.cer -inform DER -out aps.pem -outform PEM
2、push.p12导出push.pem,需要多次设置密码,这里统一设置为:abc123。
$ openssl pkcs12 -nocerts -out push.pem -in push.p12
3、用1,2得到的aps.pem和aps.push创建PKCS#12格式的文件。
$ openssl pkcs12 -export -in aps.pem -inkey push.pem -name “aps” -out aps.p12
这样我们就得到了服务端需要用到的证书文件:aps.p12
//验证
测试环境:$ openssl s_client -connect gateway.sandbox.push.apple.com:2195 -cert aps.pem -key push.pem
生产环境:$ openssl s_client -connect gateway.push.apple.com:2195 -cert aps.pem -key push.pem
最终,aps.p12和密码abc123就是服务端所需的了。