Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Send Apple Notification Service A Message With Python

I am following the documentation given with the following pyAPNS library: https://github.com/djacobs/PyAPNs

apns = APNs(use_sandbox=True, cert_file='ThePushCertificate.pem', key_file='ThePushKey.pem')
payload = Payload(alert="Checking if it works", sound="default", badge=1)
apns.gateway_server.send_notification(some_string, payload)

I am getting the following error:

SSLError: [Errno 1] _ssl.c:504: error:14094410:SSL routines:SSL3_READ_BYTES:sslv3 alert handshake failure

This error occurs on the last line of code displayed above.

What does this error mean? How do I fix this?

PS. I have been stuck on this for a couple of hours now.I found 1 similar question on here, but the answer did not really help me (for my situation). I will continue to try to figure out what's going wrong, I just felt it might be helpful if I get help from more advanced iOS / Python developers over here. Thanks!


After another day of trying to get it to work, I am stuck with a new error:

SSL_CTX_use_PrivateKey_file:PEM lib

I also went through the tutorial suggested in the answer below numerous times, but that did not help unfortunately. In the tutorial, a new combined PEM file is used, but with the repo's documentation, that file is not used, does anyone know how I should use that file?

like image 795
GangstaGraham Avatar asked May 14 '13 04:05

GangstaGraham


1 Answers

The solution to my problem was that I was using a password for the private key.

Since Keychain Access explicitly asks for a password, I thought it was necessary. It is not.

Everything worked fine when I left the password blank.

like image 108
GangstaGraham Avatar answered Oct 04 '22 21:10

GangstaGraham