实施 Apple 推送通知时出现 SSL 错误 [英] SSL error while implementing Apple Push Notification

查看:26
本文介绍了实施 Apple 推送通知时出现 SSL 错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用 python 和 django 实现 Apple 推送通知.

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

我正在使用以下库来实现它

i am using following library to implement it

http://leepa.github.com/django-iphone-push/

这是我创建发送消息的代码

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'

错误

[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.

推荐答案

我遇到了完全相同的问题.原来这是一个简单的错误 - 我在 IPHONE_SANDBOX_APN_PUSH_CERT 中出错,python 找不到我的证书.一旦我将它指向正确的位置,它就开始工作了.

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.

请注意,您可能需要先使用 openssl 命令行仔细检查您的证书,例如:

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.

另外,仔细检查证书文件的文件权限(python进程必须有足够的权限才能访问它).

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

这篇关于实施 Apple 推送通知时出现 SSL 错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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