def _read_ca_bundle(ca_bundle_file):
"""
Reads a cabundle file including certificates in PEM format
"""
logger = getLogger(__name__)
logger.debug('reading ca cabundle: %s', ca_bundle_file)
# cabundle file encoding varies. Tries reading it in utf-8 but ignore
# all errors
all_certs = codecs.open(
ca_bundle_file, 'r', encoding='utf-8', errors='ignore').read()
state = 0
contents = []
for line in all_certs.split('\n'):
if state == 0 and line.startswith('-----BEGIN CERTIFICATE-----'):
state = 1
contents.append(line)
elif state == 1:
contents.append(line)
if line.startswith('-----END CERTIFICATE-----'):
cert = load_certificate(
FILETYPE_PEM,
'\n'.join(contents).encode('utf-8'))
ROOT_CERTIFICATES_DICT[cert.get_subject().der()] = cert
state = 0
contents = []
ocsp_pyopenssl.py 文件源码
python
阅读 25
收藏 0
点赞 0
评论 0
评论列表
文章目录