當前位置: 首頁>>代碼示例>>Python>>正文


Python ExtensionOID.CERTIFICATE_POLICIES屬性代碼示例

本文整理匯總了Python中cryptography.x509.oid.ExtensionOID.CERTIFICATE_POLICIES屬性的典型用法代碼示例。如果您正苦於以下問題:Python ExtensionOID.CERTIFICATE_POLICIES屬性的具體用法?Python ExtensionOID.CERTIFICATE_POLICIES怎麽用?Python ExtensionOID.CERTIFICATE_POLICIES使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在cryptography.x509.oid.ExtensionOID的用法示例。


在下文中一共展示了ExtensionOID.CERTIFICATE_POLICIES屬性的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: test_certs

# 需要導入模塊: from cryptography.x509.oid import ExtensionOID [as 別名]
# 或者: from cryptography.x509.oid.ExtensionOID import CERTIFICATE_POLICIES [as 別名]
def test_certs(self):
        self.load_all_cas()
        self.load_all_certs()
        for name, cert in list(self.cas.items()) + list(self.certs.items()):
            try:
                val = cert.x509.extensions.get_extension_for_oid(ExtensionOID.CERTIFICATE_POLICIES).value
            except x509.ExtensionNotFound:
                continue

            for policy in val:
                pi = PolicyInformation(policy)
                self.assertEqual(pi.for_extension_type, policy)

                # pass the serialized value to the constructor and see if it's still the same
                pi2 = PolicyInformation(pi.serialize())
                self.assertEqual(pi, pi2)
                self.assertEqual(pi.serialize(), pi2.serialize())
                self.assertEqual(pi2.for_extension_type, policy) 
開發者ID:mathiasertl,項目名稱:django-ca,代碼行數:20,代碼來源:tests_extensions.py

示例2: is_certificate_extended_validation

# 需要導入模塊: from cryptography.x509.oid import ExtensionOID [as 別名]
# 或者: from cryptography.x509.oid.ExtensionOID import CERTIFICATE_POLICIES [as 別名]
def is_certificate_extended_validation(self, certificate: Certificate) -> bool:
        """Is the supplied server certificate EV?
        """
        if not self.ev_oids:
            raise ValueError("No EV OIDs supplied for {} store - cannot detect EV certificates".format(self.name))

        try:
            cert_policies_ext = certificate.extensions.get_extension_for_oid(ExtensionOID.CERTIFICATE_POLICIES)
        except ExtensionNotFound:
            return False

        for policy in cert_policies_ext.value:
            if policy.policy_identifier in self.ev_oids:
                return True
        return False 
開發者ID:nabla-c0d3,項目名稱:sslyze,代碼行數:17,代碼來源:trust_store.py

示例3: certificate_policies

# 需要導入模塊: from cryptography.x509.oid import ExtensionOID [as 別名]
# 或者: from cryptography.x509.oid.ExtensionOID import CERTIFICATE_POLICIES [as 別名]
def certificate_policies(self):
        ext = self.get_x509_extension(ExtensionOID.CERTIFICATE_POLICIES)
        if ext is not None:
            return CertificatePolicies(ext) 
開發者ID:mathiasertl,項目名稱:django-ca,代碼行數:6,代碼來源:models.py

示例4: test_as_text

# 需要導入模塊: from cryptography.x509.oid import ExtensionOID [as 別名]
# 或者: from cryptography.x509.oid.ExtensionOID import CERTIFICATE_POLICIES [as 別名]
def test_as_text(self):
        self.assertEqual(self.pi1.as_text(), 'Policy Identifier: 2.5.29.32.0\n'
                                             'Policy Qualifiers:\n* text1')
        self.assertEqual(self.pi2.as_text(), 'Policy Identifier: 2.5.29.32.0\n'
                                             'Policy Qualifiers:\n'
                                             '* UserNotice:\n'
                                             '  * Explicit text: text2')
        self.assertEqual(self.pi3.as_text(),
                         'Policy Identifier: 2.5.29.32.0\n'
                         'Policy Qualifiers:\n'
                         '* UserNotice:\n'
                         '  * Reference:\n'
                         '    * Organiziation: text3\n'
                         '    * Notice Numbers: [1]')
        self.assertEqual(self.pi4.as_text(),
                         'Policy Identifier: 2.5.29.32.0\n'
                         'Policy Qualifiers:\n'
                         '* text4\n'
                         '* UserNotice:\n'
                         '  * Explicit text: text5\n'
                         '  * Reference:\n'
                         '    * Organiziation: text6\n'
                         '    * Notice Numbers: [1, 2, 3]')
        self.assertEqual(self.pi_empty.as_text(), 'Policy Identifier: None\nNo Policy Qualifiers')

        self.load_all_cas()
        self.load_all_certs()
        for name, cert in list(self.cas.items()) + list(self.certs.items()):
            try:
                ext = cert.x509.extensions.get_extension_for_oid(ExtensionOID.CERTIFICATE_POLICIES).value
            except x509.ExtensionNotFound:
                continue

            for index, policy in enumerate(ext):
                pi = PolicyInformation(policy)
                self.assertEqual(pi.as_text(), certs[name]['policy_texts'][index]) 
開發者ID:mathiasertl,項目名稱:django-ca,代碼行數:38,代碼來源:tests_extensions.py

示例5: update_contrib

# 需要導入模塊: from cryptography.x509.oid import ExtensionOID [as 別名]
# 或者: from cryptography.x509.oid.ExtensionOID import CERTIFICATE_POLICIES [as 別名]
def update_contrib(data, cert, name, filename):
    cert_data = {
        'name': name,
        'cn': cert.cn,
        'cat': 'sphinx-contrib',
        'pub_filename': filename,
        'key_filename': False,
        'csr_filename': False,
        'valid_from': parsed.not_valid_before.strftime(_timeformat),
        'valid_until': parsed.not_valid_after.strftime(_timeformat),
        'serial': cert.serial,
        'subject': cert.distinguishedName(),
        'hpkp': cert.hpkp_pin,
        'md5': cert.get_digest('md5'),
        'sha1': cert.get_digest('sha1'),
        'sha256': cert.get_digest('sha256'),
        'sha512': cert.get_digest('sha512'),
    }

    for ext in cert.extensions:
        if isinstance(ext, Extension):
            key = OID_TO_EXTENSION[ext.oid].key
            cert_data[key] = ext.serialize()
        elif isinstance(ext, tuple):
            print('### get extension tuple!!!')
            key, value = ext
            if isinstance(value[1], x509.ObjectIdentifier):
                # Currently just some old StartSSL extensions for Netscape (!)
                continue
            else:
                cert_data[key] = value

    try:
        ext = cert.x509.extensions.get_extension_for_oid(ExtensionOID.CERTIFICATE_POLICIES).value
        cert_data['policy_texts'] = [PolicyInformation(p).as_text() for p in ext]
    except x509.ExtensionNotFound:
        pass

    data[name] = cert_data 
開發者ID:mathiasertl,項目名稱:django-ca,代碼行數:41,代碼來源:recreate-fixtures.py


注:本文中的cryptography.x509.oid.ExtensionOID.CERTIFICATE_POLICIES屬性示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。