Send Apple Notification Service Message with Python

I follow the documentation provided in 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 get the following error:

SSLError: [Errno 1] _ssl.c: 504: error: 14094410: SSL procedures: SSL3_READ_BYTES: sslv3 handshake failed

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

What does this error mean? How to fix it?

PS. I was stuck on this for a couple of hours. I found one similar question here, but the answer did not help me (for my situation). I will continue to try to find out what is going wrong, I just felt that it could be useful if I get help from more advanced iOS / Python developers. Thanks!


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

 SSL_CTX_use_PrivateKey_file:PEM lib 

I also went through the tutorial suggested in response below, but that did not help, unfortunately. The tutorial uses a new combined PEM file, but with the repo documentation this file is not used, does anyone know how I should use this file?

+7
source share
2 answers

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

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

Everything went fine when I left a blank password.

+7
source

Just try https://github.com/simonwhitaker/PyAPNs . Make sure that you have configured the certificates correctly.

Contact Raywenderlich

+3
source

All Articles