【发布时间】:2015-05-11 06:49:37
【问题描述】:
我已将我的服务器配置为仅提供 https 以创建自签名证书。我有一个客户端,我必须验证服务器的证书,然后从服务器下载文件。
如何在客户端实现验证?有代码示例吗?
我的问题与此类似:How can the SSL client validate the server's certificate? 但是虽然很好的解释,但我没有找到任何帮助。
到目前为止,我在我的代码中创建了一个目录,然后使用 urllib2 下载文件:
[...] #imports
def dir_creation(path):
try:
os.makedirs(path)
except OSError as exception:
if exception.errno != errno.EEXIST:
raise
def file_download(url):
ver_file = urllib2.urlopen(url)
data = ver_file.read()
with open(local_filename, "wb") as code:
code.write(data)
dir_creation(path)
file_download(url)
【问题讨论】:
标签: python ssl certificate verify