当前位置: 首页>>代码示例>>Python>>正文


Python x509.OtherName方法代码示例

本文整理汇总了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 
开发者ID:mathiasertl,项目名称:django-ca,代码行数:13,代码来源:extensions.py

示例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'
        )) 
开发者ID:mathiasertl,项目名称:django-ca,代码行数:6,代码来源:tests_utils.py

示例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') 
开发者ID:mathiasertl,项目名称:django-ca,代码行数:14,代码来源:tests_utils.py


注:本文中的cryptography.x509.OtherName方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。