蟒蛇:APNs SSLError [英] python: APNs SSLError

查看:25
本文介绍了蟒蛇: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 keyApple Development Push Services 下为 pkey.p12
  • Apple Development Push Services certificate as cert.p12
  • primary key under Apple Development Push Services as pkey.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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆