Windows系统下申请苹果证书并用HBuilderX打包iOS应用并提交苹果审核【超全流程】
一、准备工作
1.一台 Windows 电脑
2.安装好 OpenSSL(推荐 Win64 OpenSSL v3.5.0 Light 官网下载地址:https://slproweb.com/products/Win32OpenSSL.html)
3.拥有有效的苹果开发者账号(99美元/年)
4.安装好 HBuilderX 最新版(必须支持iOS打包)
5.项目已有正确配置的 manifest.json
二,生成生成CSR文件(证书申请文件)
1.安装OpenSSL
官网下载地址:https://slproweb.com/products/Win32OpenSSL.html
其他下载地址 https://kb.firedaemon.com/support/solutions/articles/4000121705-openssl-binary-distributions-for-microsoft-windows
安装时勾选:将OpenSSL添加到系统环境变量
D:\mac\OpenSSL\bin
推荐下载的是OpenSSL 1.1.1w LTS ZIP x86+x64 版本
那么需要在目录D:\mac\openssl-1.1.1w\openssl-1.1\x64\bin下创建一个openssl.cnf文件
内容如下
# 简易版 OpenSSL 配置文件
[ req ]
default_bits        = 2048
default_keyfile     = privkey.pem
distinguished_name  = req_distinguished_name
req_extensions      = v3_req
prompt              = no
[ req_distinguished_name ]
C = CN
ST = Henan
L = Zhengzhou
O = HubenNetwork
OU = IT
CN = 你的苹果ID邮箱
emailAddress = 你的苹果ID邮箱
[ v3_req ]
keyUsage = keyEncipherment, dataEncipherment
extendedKeyUsage = serverAuth
2. 使用命令生成私钥和CSR
打开CMD(命令提示符),输入:
cd /d D:\mac(进入你打算存放证书文件的目录,比如 D:\mac)
生成私钥:
openssl genrsa -out mykey.key 2048
生成CSR:
openssl req -new -key mykey.key -out mycsr.csr
项目 | 必填? | 备注
Country Name | 必填 | 填 CN
State / Province | 必填 | 你自己城市
Organization Name | 必填 | 公司名,没有就随便写
Common Name | 必填 | 你的Apple ID邮箱(重点)
Challenge Password | ❌ 选填 | 直接回车
Optional Company Name | ❌ 选填 | 直接回车
三、登录苹果开发者中心创建证书
登录Developer
地址:https://developer.apple.com/account/
进入 证书。
Certificates → Create Certificate
2. 选择证书类型
勾选 Apple store Distribution
3.上传CSR
上传刚才生成的 mycsr.csr 文件。
Continue → 成功后,下载 .cer 文件,比如叫 distribution.cer。
四、合成p12证书文件
1. 转换.cer文件为.pem文件
openssl x509 -in distribution.cer -inform DER -out distribution.pem -outform PEM
2. 合成p12文件
推荐生成无密码的p12,方便打包!
openssl pkcs12 -export -inkey mykey.key -in distribution.pem -out distribution.p12 -nodes
成功后,目录下出现 distribution.p12,就是打包签名用的文件!
五、注册App ID
1. 创建新的App ID
进入 Identifiers → + → Register an App ID
App Name:比如 66IMAPP
Bundle ID(包名):比如 com.wwwww.im
注意:Bundle ID 要跟 manifest.json 里的配置一致!
2. 能力配置
Push Notifications
如果App需要推送消息(manifest勾选了push模块),务必开启Push Notifications。
其他如 iCloud、In-App Purchase、Sign In with Apple,根据实际需求开启,否则默认不开。
六、创建描述文件(Provisioning Profile)
1. 创建新的Profile
进入 Profiles → 新增创建
选择类型:
打包发布用:选择 App  Connect
2. 绑定App ID和证书
选择你的App ID(如 com.hubenwang.im)
选择你的Apple Distribution证书
填写描述文件名,比如:66IMAPP_Distribution_Profile
生成后,下载 .mobileprovision 文件保存好。
八、HBuilderX打包iOS应用
常见问题
打包失败 Appid: __UNI__56290E0
Error code = -5000
Error message:
Error: certificate file(p12) import failed!
私钥证书(p12)导入失败。
解决方案
重新执行下面命令(注意没有设置密码):
openssl pkcs12 -export -inkey mykey.key -in distribution.pem -out distribution.p12 -nodes
不设置密码
九提交苹果审核
即使没有Mac苹果设备,也可以用windos上传至苹果审核。
使用 香蕉云编 https://www.yunedit.com/
或者 https://appuploader.net/
 
                    
                
 
                
            
         浙公网安备 33010602011771号
浙公网安备 33010602011771号