本文整理汇总了Python中asn1crypto.x509.GeneralName方法的典型用法代码示例。如果您正苦于以下问题:Python x509.GeneralName方法的具体用法?Python x509.GeneralName怎么用?Python x509.GeneralName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类asn1crypto.x509
的用法示例。
在下文中一共展示了x509.GeneralName方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _get_subject_alt
# 需要导入模块: from asn1crypto import x509 [as 别名]
# 或者: from asn1crypto.x509 import GeneralName [as 别名]
def _get_subject_alt(self, name):
"""
Returns the native value for each value in the subject alt name
extension that is an asn1crypto.x509.GeneralName of the type
specified by the name param.
:param name:
A unicode string use to filter the x509.GeneralName objects by -
is the name attribute of x509.GeneralName
:return:
A list of unicode strings
"""
if self._subject_alt_name is None:
return []
output = []
for general_name in self._subject_alt_name:
if general_name.name == name:
output.append(general_name.native)
return output
示例2: ocsp_url
# 需要导入模块: from asn1crypto import x509 [as 别名]
# 或者: from asn1crypto.x509 import GeneralName [as 别名]
def ocsp_url(self, value):
if value is None:
self._authority_information_access = None
return
if not isinstance(value, str_cls):
raise TypeError(_pretty_message(
'''
ocsp_url must be a unicode string, not %s
''',
_type_name(value)
))
access_description = x509.AccessDescription({
'access_method': 'ocsp',
'access_location': x509.GeneralName(
name='uniform_resource_identifier',
value=value
)
})
self._authority_information_access = x509.AuthorityInfoAccessSyntax([access_description])
示例3: test_subject_alt_name_variations
# 需要导入模块: from asn1crypto import x509 [as 别名]
# 或者: from asn1crypto.x509 import GeneralName [as 别名]
def test_subject_alt_name_variations(self):
cert = self._load_cert('chromium/subjectAltName_sanity_check.pem')
alt_names = cert.subject_alt_name_value
for general_name in alt_names:
self.assertIsInstance(general_name, x509.GeneralName)
self.assertIsInstance(alt_names[0].chosen, x509.IPAddress)
self.assertEqual(alt_names[0].chosen.native, '127.0.0.2')
self.assertIsInstance(alt_names[1].chosen, x509.IPAddress)
self.assertEqual(alt_names[1].chosen.native, 'fe80::1')
self.assertIsInstance(alt_names[2].chosen, x509.DNSName)
self.assertEqual(alt_names[2].chosen.native, 'test.example')
self.assertIsInstance(alt_names[3].chosen, x509.EmailAddress)
self.assertEqual(alt_names[3].chosen.native, 'test@test.example')
self.assertIsInstance(alt_names[4].chosen, x509.AnotherName)
self.assertEqual(alt_names[4].chosen.native, util.OrderedDict([('type_id', '1.2.3.4'), ('value', 'ignore me')]))
self.assertIsInstance(alt_names[5].chosen, x509.Name)
self.assertEqual(alt_names[5].chosen.native, util.OrderedDict([('common_name', '127.0.0.3')]))
示例4: _set_subject_alt
# 需要导入模块: from asn1crypto import x509 [as 别名]
# 或者: from asn1crypto.x509 import GeneralName [as 别名]
def _set_subject_alt(self, name, values):
"""
Replaces all existing asn1crypto.x509.GeneralName objects of the
choice represented by the name param with the values.
:param name:
A unicode string of the choice name of the x509.GeneralName object
:param values:
A list of unicode strings to use as the values for the new
x509.GeneralName objects
"""
if self._subject_alt_name is not None:
filtered_general_names = []
for general_name in self._subject_alt_name:
if general_name.name != name:
filtered_general_names.append(general_name)
self._subject_alt_name = x509.GeneralNames(filtered_general_names)
else:
self._subject_alt_name = x509.GeneralNames()
if values is not None:
for value in values:
new_general_name = x509.GeneralName(name=name, value=value)
self._subject_alt_name.append(new_general_name)
if len(self._subject_alt_name) == 0:
self._subject_alt_name = None