开发账户下,Push Notifications下,下载,会得到一个aps.cer文件。
双击 aps.cer,打开钥匙串,找到这个钥匙,导出,得到一个p12文件,自己命名。我这叫dc_zs.p12。
#将aps.cer转换成aps_dis.pem格式
openssl x509 -in aps.cer -inform DER -out aps_dis.pem -outform PEM
#将p12格式的专用密钥转换成pem,依次输入密码
openssl pkcs12 -nocerts -out APNS_Noenc.pem -in dc_zs.p12
这里必须输入密码,不然后面会报一个private错误
这里的密码位数,必须大于等于6,否则,后面还是会报一个private错误。
这是个深坑,有时候为了方便,会设置123为密码,然后,就错错错。。。。而且设置123能生成文件成功。
#创建PKCS#12格式的p12文件
openssl pkcs12 -export -in aps_dis.pem -inkey APNS_Noenc.pem -out aps_dis.p12
网络上介绍的,都带 -certfile CertificateSigningRequest.certSigningRequest ,基本上,又会报错,直接去掉这个参数。