oma*_*mat 18 python ssl apple-push-notifications
我试图通过python发送推送通知到这里所述,但我收到以下错误:
Traceback (most recent call last):
File "<console>", line 1, in <module>
File "/home/omat/CA/server/ca/models.py", line 193, in push
c.connect((host_name, 2195))
File "/usr/lib/python2.6/ssl.py", line 307, in connect
self.ca_certs)
SSLError: [Errno 336265225] _ssl.c:337: error:140B0009:SSL routines:
SSL_CTX_use_PrivateKey_file:PEM lib
Run Code Online (Sandbox Code Playgroud)
回溯说,错误是从python ssl模块中引发的,但是消息不对我唱歌.关于可能出错的任何想法?
谢谢,
OMAT
编辑:
使用的证书是根据证书和私钥创建的,如下所示:
openssl pkcs12 -clcerts -nokeys -out apns-dev-cert.pem -in apns-dev-cert.p12
openssl pkcs12 -nocerts -out apns-dev-key.pem -in apns-dev-key.p12
cat apns-dev-cert.pem apns-dev-key.pem > apns-dev.pem
Run Code Online (Sandbox Code Playgroud)
oma*_*mat 39
以下是我如何使用它:
从KeyChain中导出以下两种p12
格式,而不提供密码:
Apple Development Push Services
证书 cert.p12
primary key
下Apple Development Push Services
为pkey.p12
在终端中,转到导出证书的目录,并将p12
文件转换为pem
格式并按如下方式连接它们:
$ openssl pkcs12 -in pkey.p12 -out pkey.pem -nodes -clcerts
$ openssl pkcs12 -in cert.p12 -out cert.pem -nodes -clcerts
$ cat cert.pem pkey.pem > iphone_ck.pem
Run Code Online (Sandbox Code Playgroud)
iphone_ck.pem
是您需要的证书.
cor*_*sen 13
我使用PyAPNs遇到了相同的错误消息.这个例子说是像这样启动它:
apns = APNs(use_sandbox=True, cert_file='cert.pem', key_file='key.pem')
Run Code Online (Sandbox Code Playgroud)
事实证明我的问题的解决方案是包括每个.pem文件的完整系统路径:
cert_path = os.path.join(os.path.dirname(__file__), 'cert.pem')
key_path = os.path.join(os.path.dirname(__file__), 'key.pem')
apns = APNs(use_sandbox=True, cert_file=cert_path, key_file=key_path)
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
11859 次 |
最近记录: |