buildCer.sh
2.03 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
#!/bin/bash
# 创建推送证书的完整脚本. 使用 OpenSSL 命令行
echo "🚀 开始创建推送证书所需文件..."
# 创建目录
mkdir -p ~/Desktop/APNSCertificate
cd ~/Desktop/APNSCertificate
# 1. 生成私钥
echo "1. 生成私钥..."
openssl genrsa -out apns_private.key 2048
echo "✅ 私钥已生成: apns_private.key"
# 2. 生成 CSR
echo "2. 生成 CSR 文件..."
# openssl req -new \
# -key apns_private.key \
# -out CertificateSigningRequest.certSigningRequest \
# -subj "/emailAddress=your.email@company.com/CN=APNS Certificate/O=$(whoami)/C=US"
openssl req -new \
-key apns_private.key \
-out CertificateSigningRequestApns.certSigningRequest \
-subj "/emailAddress=info@banxiaoer.com/CN=APNS Certificate/O=ZhongshanBanXiaoEr/C=US"
# 3. 创建 PEM 格式(备用)
openssl rsa -in apns_private.key -out apns_private.pem
echo "✅ CSR 已生成: CertificateSigningRequest.certSigningRequest"
echo ""
echo "📋 下一步操作:"
echo "1. 访问 https://developer.apple.com"
echo "2. 进入 Certificates → Add (+)"
echo "3. 选择 'Apple Push Notification service SSL (Sandbox & Production)'"
echo "4. 选择你的 App ID"
echo "5. 上传此文件夹中的 CertificateSigningRequest.certSigningRequest"
echo "6. 下载证书文件 (.cer)"
echo ""
echo "⚠️ 重要:请保管好 apns_private.key 文件!"
security find-identity -p codesigning -v
security find-certificate -c "Apple Push Services" -Z
#############
创建 .p12 文件
#!/bin/bash
# 将 .cer 文件转换为 .p12
# 假设你的文件在桌面 APNSCertificate 文件夹
cd ~/Desktop/APNSCertificate
# 1. 将 .cer 转换为 .pem
echo "将 .cer 证书转换为 PEM 格式..."
openssl x509 -in "你的证书文件名.cer" -inform DER -out certificate.pem
# 2. 创建 .p12 文件
echo "创建 .p12 文件..."
openssl pkcs12 -export \
-inkey apns_private.key \
-in certificate.pem \
-out apns_certificate.p12
echo "✅ 完成!"
echo "📁 .p12 文件: apns_certificate.p12"
echo "🔑 需要设置密码(推送服务器配置时会用到)"