本文整理匯總了Python中cryptography.x509.oid.ExtensionOID.BASIC_CONSTRAINTS屬性的典型用法代碼示例。如果您正苦於以下問題:Python ExtensionOID.BASIC_CONSTRAINTS屬性的具體用法?Python ExtensionOID.BASIC_CONSTRAINTS怎麽用?Python ExtensionOID.BASIC_CONSTRAINTS使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在類cryptography.x509.oid.ExtensionOID
的用法示例。
在下文中一共展示了ExtensionOID.BASIC_CONSTRAINTS屬性的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: is_ca
# 需要導入模塊: from cryptography.x509.oid import ExtensionOID [as 別名]
# 或者: from cryptography.x509.oid.ExtensionOID import BASIC_CONSTRAINTS [as 別名]
def is_ca(certificate):
# TODO: test self signed if no extensions found
extensions = certificate.extensions
try:
return extensions.get_extension_for_oid(ExtensionOID.BASIC_CONSTRAINTS).value.ca
except x509.ExtensionNotFound:
try:
return extensions.get_extension_for_oid(ExtensionOID.KEY_USAGE).value.key_cert_sign
except x509.ExtensionNotFound:
pass
return False
示例2: basic_constraints
# 需要導入模塊: from cryptography.x509.oid import ExtensionOID [as 別名]
# 或者: from cryptography.x509.oid.ExtensionOID import BASIC_CONSTRAINTS [as 別名]
def basic_constraints(self):
ext = self.get_x509_extension(ExtensionOID.BASIC_CONSTRAINTS)
if ext is not None:
return BasicConstraints(ext)
示例3: pathlen
# 需要導入模塊: from cryptography.x509.oid import ExtensionOID [as 別名]
# 或者: from cryptography.x509.oid.ExtensionOID import BASIC_CONSTRAINTS [as 別名]
def pathlen(self):
"""The ``pathlen`` attribute of the ``BasicConstraints`` extension (either an ``int`` or ``None``)."""
try:
ext = self.x509.extensions.get_extension_for_oid(ExtensionOID.BASIC_CONSTRAINTS)
except x509.ExtensionNotFound: # pragma: no cover - extension should always be present
return None
return ext.value.path_length