[pyOpenSSL-Users] sslv3 alert handshake failure

N T H tentoilatentoi at yahoo.com
Thu Oct 23 09:18:44 CEST 2014


Hi all,

I was trying connect to Apple Push Notification Service with sandbox mode
 - use openssl-1.0.1e: OK, below is command:

   #openssl s_client -cert file_cert.pem -key file_key.pem -CAfile entrust_2048_ca.cer -host gateway.sandbox.push.apple.com -port 2195

 - use pyOpenSSL-0.1.4: I got error 'sslv3 alert handshake failure', below my python code:   
   
   context = OpenSSL.SSL.Context(OpenSSL.SSL.SSLv3_METHOD)
   context.load_verify_locations("entrust_2048_ca.cer")
   context.set_verify(OpenSSL.SSL.VERIFY_PEER, lambda conn, cert, errno, depth, preverify_ok: preverify_ok)
   passphrase = six.b(passphrase)
   with open(cert_file, 'rb') as fp:
       cert_string = fp.read()
   cert = OpenSSL.crypto.load_certificate(OpenSSL.crypto.FILETYPE_PEM, cert_string)
   context.use_certificate(cert)
   with open(key_file, 'rb') as fp:
       key_string = fp.read()
   args = [OpenSSL.crypto.FILETYPE_PEM, key_string, passphrase]
   pk = OpenSSL.crypto.load_privatekey(*args)
   context.use_privatekey(pk)
   context.check_privatekey()
   socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
   ssl_conn = OpenSSL.SSL.Connection(context, socket)
   ssl_conn.connect(("gateway.sandbox.push.apple.com", 2195))
   ssl_conn.setblocking(1)
   ssl_conn.do_handshake()
   
I'm using Python 2.7.3, Debian wheezy.
Entrust_2048_ca.cer file was downloaded from https://www.entrust.net/downloads/binary/entrust_2048_ca.cer
Can you help me?
Thanks
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/pyopenssl-users/attachments/20141023/50f827d3/attachment.html>


More information about the pyopenssl-users mailing list