如何测试我的开发ASPN证书是否有效?
我的python脚本出现以下错误:
Traceback (most recent call last):
File "pushnot.py", line 15, in <module>
wrapper.notify()
File "build/bdist.macosx-10.9-intel/egg/APNSWrapper/notifications.py", line 194, in notify
File "build/bdist.macosx-10.9-intel/egg/APNSWrapper/connection.py", line 215, in connect
File "build/bdist.macosx-10.9-intel/egg/APNSWrapper/connection.py", line 161, in connect
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/ssl.py", line 333, in connect
self._real_connect(addr, False)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/ssl.py", line 323, in _real_connect
self.do_handshake()
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/ssl.py", line 305, in do_handshake
self._sslobj.do_handshake()
ssl.SSLError: [Errno 1] _ssl.c:504: error:14094410:SSL routines:SSL3_READ_BYTES:sslv3 alert handshake failure
知道为什么吗?
答案 0 :(得分:3)
我设法通过使用TLSv1而不是SSLv3来建立与APNS服务器的连接来解决这个问题。问题在于python SSL库链接到过时的OSX OpenSSL库(我的机器上的v0.9.8)。当使用SSLv3时,此版本显然不再与APNS服务器建立正确的连接。因此,在设置连接时,请将ssl_version设置为PROTOCOL_TLSv1,如下所示:
sock = socket()
sock = ssl.wrap_socket(sock, ssl_version=ssl.PROTOCOL_TLSv1, certfile=certfile)
sock.connect(('sandbox.push.apple.com, 2195))
您不应再收到握手失败错误。