java apns ssl错误,在实施苹果推送通知SSL错误

I am trying to implement Apple Push Notification using python and django.

i am using following library to implement it

Here is my code that create that send the message

from django.http import HttpResponse

from django.utils import simplejson

import json

from push.models import iPhone

def SendMessage(request,data):

t = iPhone('XXXXXXXX XXXXXXXX XXXXXXXX XXXXXXXX XXXXXXXX ') # 64 digit token

t.send_message("hi") # at this line i am getting ERROR

return HttpResponse(data,mimetype='application/javascript')

settings.py

import os

PROJECT_ROOT = '/'

# Full path to the APN Certificate / Private Key .pem

IPHONE_SANDBOX_APN_PUSH_CERT = os.path.join(PROJECT_ROOT, "apns-dev-tubeteam.pem")

IPHONE_LIVE_APN_PUSH_CERT = os.path.join(PROJECT_ROOT, "apns-dev-tubeteam.pem")

# Set this to the hostname for the outgoing push server

IPHONE_SANDBOX_APN_HOST = 'gateway.sandbox.push.apple.com'

IPHONE_LIVE_APN_HOST = 'gateway.push.apple.com'

# Set this to the hostname for the feedback server

IPHONE_SANDBOX_FEEDBACK_HOST = 'feedback.sandbox.push.apple.com'

IPHONE_LIVE_FEEDBACK_HOST = 'feedback.push.apple.com'

Error

[Errno 336265218] _ssl.c:337: error:140B0002:SSL routines:SSL_CTX_use_PrivateKey_file:system lib

Can anyone please do tell me how to get rid off it.

解决方案

I had the exact same problem. Turns out it was a simple error - I had a mistake in IPHONE_SANDBOX_APN_PUSH_CERT and python could not locate my certificate. Once I pointed it to the right location, it started working.

Note that you might want to double-check your certificate first using openssl command line, such as:

openssl x509 -text -in cert.pem

That will give you textual information about your certificate, its validity, etc.

Also, double-check file permissions of the certificate file (the python process must have sufficient rights to access it).

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值