本文整理汇总了Python中ndg.httpsclient.ssl_peer_verification.SUBJ_ALT_NAME_SUPPORT属性的典型用法代码示例。如果您正苦于以下问题:Python ssl_peer_verification.SUBJ_ALT_NAME_SUPPORT属性的具体用法?Python ssl_peer_verification.SUBJ_ALT_NAME_SUPPORT怎么用?Python ssl_peer_verification.SUBJ_ALT_NAME_SUPPORT使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类ndg.httpsclient.ssl_peer_verification
的用法示例。
在下文中一共展示了ssl_peer_verification.SUBJ_ALT_NAME_SUPPORT属性的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: get_subj_alt_name
# 需要导入模块: from ndg.httpsclient import ssl_peer_verification [as 别名]
# 或者: from ndg.httpsclient.ssl_peer_verification import SUBJ_ALT_NAME_SUPPORT [as 别名]
def get_subj_alt_name(peer_cert):
# Search through extensions
dns_name = []
if not SUBJ_ALT_NAME_SUPPORT:
return dns_name
general_names = SubjectAltName()
for i in range(peer_cert.get_extension_count()):
ext = peer_cert.get_extension(i)
ext_name = ext.get_short_name()
if ext_name != b'subjectAltName':
continue
# PyOpenSSL returns extension data in ASN.1 encoded form
ext_dat = ext.get_data()
decoded_dat = der_decoder.decode(ext_dat,
asn1Spec=general_names)
for name in decoded_dat:
if not isinstance(name, SubjectAltName):
continue
for entry in range(len(name)):
component = name.getComponentByPosition(entry)
if component.getName() != 'dNSName':
continue
dns_name.append(str(component.getComponent()))
return dns_name
示例2: get_subj_alt_name
# 需要导入模块: from ndg.httpsclient import ssl_peer_verification [as 别名]
# 或者: from ndg.httpsclient.ssl_peer_verification import SUBJ_ALT_NAME_SUPPORT [as 别名]
def get_subj_alt_name(peer_cert):
# Search through extensions
dns_name = []
if not SUBJ_ALT_NAME_SUPPORT:
return dns_name
general_names = SubjectAltName()
for i in range(peer_cert.get_extension_count()):
ext = peer_cert.get_extension(i)
ext_name = ext.get_short_name()
if ext_name != 'subjectAltName':
continue
# PyOpenSSL returns extension data in ASN.1 encoded form
ext_dat = ext.get_data()
decoded_dat = der_decoder.decode(ext_dat,
asn1Spec=general_names)
for name in decoded_dat:
if not isinstance(name, SubjectAltName):
continue
for entry in range(len(name)):
component = name.getComponentByPosition(entry)
if component.getName() != 'dNSName':
continue
dns_name.append(str(component.getComponent()))
return dns_name
示例3: get_subj_alt_name
# 需要导入模块: from ndg.httpsclient import ssl_peer_verification [as 别名]
# 或者: from ndg.httpsclient.ssl_peer_verification import SUBJ_ALT_NAME_SUPPORT [as 别名]
def get_subj_alt_name(peer_cert):
# Search through extensions
dns_name = []
if not SUBJ_ALT_NAME_SUPPORT:
return dns_name
general_names = SubjectAltName()
for i in range(peer_cert.get_extension_count()):
ext = peer_cert.get_extension(i)
ext_name = ext.get_short_name()
if ext_name.decode() != 'subjectAltName':
continue
# PyOpenSSL returns extension data in ASN.1 encoded form
ext_dat = ext.get_data()
decoded_dat = der_decoder.decode(ext_dat,
asn1Spec=general_names)
for name in decoded_dat:
if not isinstance(name, SubjectAltName):
continue
for entry in range(len(name)):
component = name.getComponentByPosition(entry)
if component.getName() != 'dNSName':
continue
dns_name.append(str(component.getComponent()))
return dns_name