dimension_apn/apple_cert.md

32 lines
1.7 KiB
Markdown
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

## 苹果推送服务证书申请流程
### 1. 申请CRS文件
1. 在macos下使用 钥匙串服务
2. ![img.png](img.png)
3. 填写信息
3.1 用户电子邮箱地址: 填写项目的苹果开发者账号的邮箱,很重要!!
3.2 常用名称填写和app相关的名称: dimension push apns
3.3 CA电子邮箱地址 留空
3.4 请求是:一定要选择存储到磁盘
4. 点击“继续”会生成CSR文件这个文件用用到在第二步里面用来在苹果后台生成 cer文件
### 2. 登陆苹果开发后台
2.1: Certificates => 选择添加 => Services => Apple Push Notification service SSL (Sandbox & Production)
2.2 选择第一步生成的 CSR 文件,下载 cer文件
2.3 选择用 "钥匙串服务" 打开
2.4 在登陆项下,选择密钥,选择对应的文件, 并导出为 .p12 文件格式
![img_1.png](img_1.png)
2.5 将p12文件转换成推送服务器需要pem文件
openssl pkcs12 -in apns_push_key.p12 -out apns_push_key.pem -nodes -legacy
添加-legacy参数可以让 OpenSSL 使用传统加密算法支持模式,这通常能解决兼容性问题。 之前没有使用 -legacy参数导致解析失败!!
2.6 将pem文件分离成.cert和.key文件
# 提取证书部分到cert.pem
openssl x509 -in combined.pem -out cert.pem
# 提取私钥部分到private.key
openssl rsa -in combined.pem -out private.key
### 3. 推送服务的证书有效为1年需要及时更新; 统一了开发环境和正式环境的证书
3.1 开发环境 api.sandbox.push.apple.com
3.2 正式环境 api.push.apple.com
### 4. 研究整个流程花费了1天时间