Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Connecting to APNS for iPhone Using Python

I'm trying to send push notifications to an iPhone using Python. I've exported my certificate and private key into a p12 file from keychain access and then converted it into pem file using the following command:

openssl pkcs12 -in cred.p12 -out cert.pem -nodes -clcerts

I'm using APNSWrapper in Python for the connection.

I run the following code:

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()

And then I get the error message:

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

Can anyone help me out on this?

like image 482
elioty Avatar asked Jul 23 '09 15:07

elioty


1 Answers

I recently did this using Django - http://leecutsco.de/2009/07/14/push-on-the-iphone/

May be useful? It's making use of no extra libraries other than those included with Python already. Wouldn't take much to extract the send_message() method out.

like image 145
Lee Avatar answered Nov 13 '22 06:11

Lee