我是学习python的第一步,请原谅我的问题。我想运行下面的代码(取自:http ://docs.python.org/library/ssl.html ):
import socket, ssl, pprint
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
# require a certificate from the server
ssl_sock = ssl.wrap_socket(s,
ca_certs="F:/cert",
cert_reqs=ssl.CERT_REQUIRED)
ssl_sock.connect(('www.versign.com', 443))
print repr(ssl_sock.getpeername())
print ssl_sock.cipher()
print pprint.pformat(ssl_sock.getpeercert())
# Set a simple HTTP request -- use httplib in actual code.
ssl_sock.write("""GET / HTTP/1.0\r
Host: www.verisign.com\r\n\r\n""")
# Read a chunk of data. Will not necessarily
# read all the data returned by the server.
data = ssl_sock.read()
# note that closing the SSLSocket will also close the underlying socket
ssl_sock.close()
我收到以下错误:
回溯(最后一次调用):文件“C:\Users\e\workspace\PythonTesting\source\HelloWorld.py”,第 38 行,在 ssl_sock.connect(('www.versign.com', 443))
文件“C:\Python27\lib\ssl.py”,第 331 行,在连接中
self._real_connect(addr, False)
_real_connect 中的文件“C:\Python27\lib\ssl.py”,第 314 行
self.ca_certs,self.ciphers)
ssl.SSLError: [Errno 185090050] _ssl.c:340: 错误:0B084002:x509 证书例程:X509_load_cert_crl_file:system lib
python 中的错误报告看起来并不指导找到问题的根源。我可能弄错了。谁能帮忙告诉我代码中的问题是什么?