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


Python x509.GeneralName方法代码示例

本文整理汇总了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 
开发者ID:wbond,项目名称:certbuilder,代码行数:24,代码来源:__init__.py

示例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]) 
开发者ID:wbond,项目名称:certbuilder,代码行数:24,代码来源:__init__.py

示例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')])) 
开发者ID:wbond,项目名称:asn1crypto,代码行数:19,代码来源:test_x509.py

示例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 
开发者ID:wbond,项目名称:certbuilder,代码行数:32,代码来源:__init__.py


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