APNs - fancyfsz/FancyWiki GitHub Wiki

苹果推送服务APNS

Apple Push Notification Service

APNs_1

可以简单把Provider理解为游戏服务器,APNS理解为苹果服务器,ClientApp理解为游戏客户端。

以下为更为详细的一个流程图:

APNs_2

PEM format which stands for Privacy Enhanced Mail is a Base64 encoded DER certificate.

生成PEM文件:

certP12FileName=$1
keyP12FileName=$2
needPassword=$3

openssl pkcs12 -clcerts -nokeys -out cert.pem -in $certP12FileName
if [ "$needPassword" = true ](/fancyfsz/FancyWiki/wiki/-"$needPassword"-=-true-); then
	openssl pkcs12 -nocerts -out key.pem -in $keyP12FileName
else
# "Enter PEM pass phrase" because openssl doesn't want to output private key in clear text. The password is used to output encrypted private key
# Below command can be used to output private key in clear text. No password is then asked.
# -nodes stands for No DES, meaning OpenSSL won't encrypt the output
	openssl pkcs12 -nocerts -nodes -out key.pem -in $keyP12FileName
fi

cat cert.pem key.pem > ck.pem

验证PEM文件:

openssl s_client -connect gateway.sandbox.push.apple.com:2195 -cert cert.pem -key key.pem

https://juejin.cn/post/6844903893592178696

如果遇到以下的报错

009010D701000000:error:0308010C:digital envelope routines:inner_evp_generic_fetch:unsupported:crypto/evp/evp_fetch.c:341:Global default library context, Algorithm (RC2-40-CBC : 0), Properties ()

解决方案可以是添加一个-legacy参数,详见下文

https://www.iclarified.com/92617/how-to-fix-error-0308010c-digital-envelope-routines-unsupported