當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。