[Django]-Apple push notifications script not working suddenly

3๐Ÿ‘

โœ…

I managed to fix this by using TLSv1 instead of SSLv3 to make a connection to the APNS server. The problem is with the python SSL library linking against the outdated OSX OpenSSL library (v0.9.8 on my machine). This version apparently no longer makes correct connections to the APNS server when SSLv3 is used. So instead, set the ssl_version to PROTOCOL_TLSv1 when setting up your connection, like so:

sock = socket()
sock = ssl.wrap_socket(sock, ssl_version=ssl.PROTOCOL_TLSv1, certfile=certfile)
sock.connect(('sandbox.push.apple.com, 2195))

And you should no longer get the handshake failure error.

๐Ÿ‘คalex-mcleod

Leave a comment