apns pem 推送证书生成

  1. Certificates, Identifiers & Profiles,下载 Apple Push Services文件,生成的是 apns.cer,将cer双击导入到苹果系统。

  2. 从钥匙串中导出p12文件,证书和证书的key,注意设置安全密码:
    file

  3. 通过命令行开始生成

    cert:
    openssl pkcs12 -clcerts -nokeys -out apns_cert.pem -in apns_cert.p12
    key:
    openssl pkcs12 -nocerts -out apns_cert_key.pem -in apns_cert_key.p12

    这个过程会提示你输入之前的文件的密码,以及新生成的文件的密码,一定要区分清楚,因为后面的程序调试是需要生成文件的密码的。

  4. 将两个pem合成一个

    cat apns_cert.pem apns_cert_key.pem > ck.pem
  5. 验证
    开发证书:
    openssl s_client -connect gateway.sandbox.push.apple.com:2195 -cert apns_cert.pem -key apns_cert_key.pem
    量产证书:
    openssl s_client -connect gateway.push.apple.com:2195 -cert apns_cert.pem -key apns_cert_key.pem
    如果验证成功,内容结尾显示如下:

    SSL-Session:
    Protocol  : TLSv1.2
    Cipher    : DES-CBC3-SHA
    Session-ID: 
    Session-ID-ctx: 
    Master-Key: xxx
    Start Time: 1627218051
    Timeout   : 7200 (sec)
    Verify return code: 0 (ok)

    Verify return code: 0 (ok),说明成功。

发表回复

您的电子邮箱地址不会被公开。 必填项已用*标注