def save_certificate(self):
port = self.url.port if self.url.port else 443
adr = (self.url.hostname, port)
if self.debug: print("save_certificate of %s to %s" % (str(adr), self.cafile))
capath = os.path.dirname(self.cafile)
if not os.path.exists(capath): os.makedirs(capath)
cert = ssl.get_server_certificate(adr)
with open(self.cafile, "w") as outfile:
outfile.write(cert)
评论列表
文章目录