使用Python连接到iPhone的APNS

eli*_*oty 12 python iphone ssl push-notification

我正在尝试使用Python向iPhone发送推送通知.我已经将我的证书和私钥从keychain访问导出到p12文件中,然后使用以下命令将其转换为pem文件:

openssl pkcs12 -in cred.p12 -out cert.pem -nodes -clcerts
Run Code Online (Sandbox Code Playgroud)

我正在使用Python中的APNSWrapper进行连接.

我运行以下代码:

deviceToken = 'Qun\xaa\xd ... c0\x9c\xf6\xca' 

# create wrapper
wrapper = APNSNotificationWrapper('/path/to/cert/cert.pem', True)

# create message
message = APNSNotification()
message.token(deviceToken)
message.badge(5)

# add message to tuple and send it to APNS server
wrapper.append(message)
wrapper.notify()

然后我收到错误消息:

ssl.SSLError: (1, '_ssl.c:485: 
error:14094416:SSL routines:SSL3_READ_BYTES:sslv3 alert certificate unknown')

任何人都可以帮我解决这个问题吗?

Lee*_*Lee 8

我最近使用Django做到了这一点 - http://leecutsco.de/2009/07/14/push-on-the-iphone/

可能有用吗?除了Python中包含的库以外,它没有使用额外的库.提取send_message()方法并不需要太多.