本文整理汇总了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)
示例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
示例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)
示例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])
示例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