蟒蛇:APNs SSLError [英] python: APNs SSLError
问题描述
我正在尝试通过 python 向 iPhone 发送推送通知,如 此处 但我收到以下错误:
I am trying to send push notifications to iPhone via python as described here but I am getting the following error:
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
错误是从 python ssl 模块中引发的,如回溯所述,但消息没有向我发出.关于可能出什么问题的任何想法?
The error is raised from within the python ssl module as the traceback says but the message doesn't sing to me. Any ideas on what might be wrong?
谢谢,
oMat
使用的证书是根据证书和私钥创建的,如下所示:
The certificate used is created from the certificate and the private key as follows:
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
推荐答案
这是我如何让它工作的:
Here is how I get it working:
从 KeyChain 中以 p12
格式导出以下两个内容,无需提供密码:
From within KeyChain export the following both in p12
format, without giving password:
Apple Development Push Services
证书为cert.p12
primary key
在Apple Development Push Services
下为pkey.p12
Apple Development Push Services
certificate ascert.p12
primary key
underApple Development Push Services
aspkey.p12
在终端中转到您导出证书的目录并将p12
文件转换为pem
格式并按如下方式连接它们:
In terminal go to the directory where you have exported the certificates and convert the p12
files to pem
format and concatenate them as follows:
$ 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
iphone_ck.pem
就是你需要的证书.
这篇关于蟒蛇:APNs SSLError的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!