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

查看:612
本文介绍了蟒蛇:的APN SSLError的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图通过Python描述推送通知给iPhone此处,但我收到以下错误:

 回溯(最后最近一次调用):
  文件<&控制台GT;,1号线,上述<&模块GT;
  文件/home/omat/CA/server/ca/models.py,线路193,在推
    c.connect((HOST_NAME,2195))
  文件/usr/lib/python2.6/ssl.py,307线,在连接
    self.ca_certs)
SSLError:[错误336265225] _ssl.c:337:错误:140B0009:SSL例程:
  SSL_CTX_use_PrivateKey_file:PEM LIB

该错误是从Python SSL模块内的回溯说,但该消息不唱歌给我提出。什么任何想法可能是错误的?

谢谢,

OMAT

编辑:

用于从证书和私钥创建的证书如下:

  OpenSSL的PKCS12 -clcerts -nokeys退房手续APNS-DEV-cert.pem -in APNS-DEV-cert.p12
OpenSSL的PKCS12 -nocerts退房手续APNS-DEV-ke​​y.pem -in APNS-DEV-ke​​y.p12
猫APNS-DEV-cert.pem APNS-DEV-ke​​y.pem> APNS-dev.pem


下面是我如何得到它的工作:

从内钥匙链导出以下无论是在 P12 格式,不给密码:


  • 苹果开发推送服务作为证书 cert.p12

  • 主键苹果开发推送服务 pkey.p12

在终端前往您所导出证书的目录和文件转换 P12到 PEM 格式将它们连接起来如下:

  $的openssl的pkcs12 -in pkey.p12退房手续pkey.pem -nodes -clcerts
$ OpenSSL的PKCS12 -in cert.p12退房手续cert.pem -nodes -clcerts
$猫cert.pem pkey.pem> iphone_ck.pem

iphone_ck.pem 是你所需要的证书。

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

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?

Thanks,

oMat

edit:

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:

From within KeyChain export the following both in p12 format, without giving password:

  • Apple Development Push Services certificate as cert.p12
  • primary key under Apple Development Push Services as pkey.p12

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 is the certificate you need.

这篇关于蟒蛇:的APN SSLError的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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