我有以下简单的 python 代码,旨在执行 ssl 握手并验证客户端和服务器之间的证书:
ssl_test.py:
import ssl
import socket
s = socket.socket()
print "connecting..."
#logging.debug("Connecting")
# Connect with SSL mutual authentication
# We only trust our server's CA, and it only trusts user certificates signed by it
c = ssl.wrap_socket(s, cert_reqs=ssl.CERT_REQUIRED,
ssl_version=ssl.PROTOCOL_SSLv3, ca_certs='ca.crt',
certfile='user.crt', keyfile='user.key')
c.connect((constants.server_addr, constants.port))
当我执行此操作时,我收到以下错误。
>python ssl_test.py
Traceback (most recent call last):
File "ssl_test.py", line 12, in <module>
c.connect(('192.168.1.82', 7070))
File "C:\Python27\lib\ssl.py", line 331, in connect
self._real_connect(addr, False)
File "C:\Python27\lib\ssl.py", line 314, in _real_connect
self.ca_certs, self.ciphers)
ssl.SSLError: [Errno 0] _ssl.c:340: error:00000000:lib(0):func(0):reason(0)
这个错误是什么意思,我该如何解决?