本文整理汇总了Python中cryptography.x509.OtherName方法的典型用法代码示例。如果您正苦于以下问题:Python x509.OtherName方法的具体用法?Python x509.OtherName怎么用?Python x509.OtherName使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类cryptography.x509
的用法示例。
在下文中一共展示了x509.OtherName方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: get_common_name
# 需要导入模块: from cryptography import x509 [as 别名]
# 或者: from cryptography.x509 import OtherName [as 别名]
def get_common_name(self):
"""Get a value suitable for use as CommonName in a subject, or None if no such value is found.
This function returns a string representation of the first value that is not a DirectoryName,
RegisteredID or OtherName.
"""
for name in self.value:
if isinstance(name, (x509.DirectoryName, x509.RegisteredID, x509.OtherName)):
continue
return name.value
示例2: test_othername
# 需要导入模块: from cryptography import x509 [as 别名]
# 或者: from cryptography.x509 import OtherName [as 别名]
def test_othername(self):
self.assertEqual(parse_general_name('otherName:2.5.4.3;UTF8:example.com'), x509.OtherName(
NameOID.COMMON_NAME, b'example.com'
))
示例3: test_otherName_octetString
# 需要导入模块: from cryptography import x509 [as 别名]
# 或者: from cryptography.x509 import OtherName [as 别名]
def test_otherName_octetString(self):
self.assertEqual(parse_general_name(
'otherName:1.3.6.1.4.1.311.25.1;OctetString:09CFF1A8F6DEFD4B85CE95FFA1B54217'),
x509.OtherName(
x509.oid.ObjectIdentifier('1.3.6.1.4.1.311.25.1'),
b'\x04\x10\t\xcf\xf1\xa8\xf6\xde\xfdK\x85\xce\x95\xff\xa1\xb5B\x17'))
with self.assertRaisesRegex(ValueError, '^Incorrect otherName format: foobar$'):
parse_general_name('otherName:foobar')
with self.assertRaisesRegex(ValueError, '^Unsupported ASN type in otherName: MagicString$'):
parse_general_name('otherName:1.2.3;MagicString:Broken')