本文整理匯總了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')