[英]ssl.SSLError when sending Push message using PyAPNS
I've been trying to access the APNS in order to send push notifications to an iOS app I develop. 我一直在尝试访问APNS,以便向我开发的iOS应用发送推送通知。 I have created a development and production certificate requests and signed them on the Apple dev center: 我创建了开发和生产证书申请,并在Apple开发中心上签名了:
For each certificate (production and development), I have three files: 对于每个证书(生产和开发),我都有三个文件:
aps_development.cer: A
.cer` file I have downloaded from Apple after signing the certificate request. aps_development.cer: A
我在签署证书申请后从Apple下载了aps_development.cer: A
.cer`文件。 dev.pem
: A .pem
public key file from the OSX keychain. dev.pem
:OSX钥匙串中的.pem
公钥文件。 dev.p12
: A .p12
private key file from the OSX keychain, with password (and dev_nopass.p12
: A .p12
private key file from the OSX keychain, with password). dev.p12
:来自OSX钥匙串的.p12
私钥文件,带有密码(而dev_nopass.p12
:来自OSX钥匙串的.p12
私钥文件,带有密码)。 from apns import APNs, Frame, Payload 从apns导入apns,框架,有效载荷
p12 = '/path/to/dev.p12'
p12_nopass = '/path/to/dev_nopass.p12'
pem = '/path/to/dev.pem'
cer = '/path/to/aps_development.cer'
apns = APNs(use_sandbox=True,
cert_file=pem,
key_file=p12_nopass)
# Send a notification
# Dummy token, but it does not cause the error (SSL fails before token check)
token_hex = 'b5bb9d8014a0f9b1d61e21e796d78dccdf1352f23cd32812f4850b87'
payload = Payload(alert="Hello World!", sound="default", badge=1)
apns.gateway_server.send_notification(token_hex, payload)
Result: 结果:
Traceback (most recent call last):
File "apple_push_driver.py", line 18, in <module>
apns.gateway_server.send_notification(token_hex, payload)
File "/path_to/site-packages/apns.py", line 381, in send_notification
self.write(self._get_notification(token_hex, payload))
File "/path_to/apns.py", line 174, in write
return self._connection().write(string)
File "/path_to/apns.py", line 167, in _connection
self._connect()
File "/path_to/apns.py", line 151, in _connect
self._ssl = wrap_socket(self._socket, self.key_file, self.cert_file)
File "/path_to/ssl.py", line 387, in wrap_socket
ciphers=ciphers)
File "/path_to/ssl.py", line 141, in __init__
ciphers)
ssl.SSLError: [Errno 336265225] _ssl.c:351: error:140B0009:SSL routines:SSL_CTX_use_PrivateKey_file:PEM lib
I tried both p12
and p12_nopass
, production and dev, and got the same results. 我同时尝试了p12
和p12_nopass
,production和dev,并获得了相同的结果。
Any idea why I can't make SSL connection in order to send a Push notification via PyAPNs? 知道为什么我无法建立SSL连接才能通过PyAPN发送推送通知吗?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.