本文整理匯總了Python中cryptography.x509.oid.ExtensionOID.KEY_USAGE屬性的典型用法代碼示例。如果您正苦於以下問題:Python ExtensionOID.KEY_USAGE屬性的具體用法?Python ExtensionOID.KEY_USAGE怎麽用?Python ExtensionOID.KEY_USAGE使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在類cryptography.x509.oid.ExtensionOID
的用法示例。
在下文中一共展示了ExtensionOID.KEY_USAGE屬性的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: is_ca
# 需要導入模塊: from cryptography.x509.oid import ExtensionOID [as 別名]
# 或者: from cryptography.x509.oid.ExtensionOID import KEY_USAGE [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: key_usage
# 需要導入模塊: from cryptography.x509.oid import ExtensionOID [as 別名]
# 或者: from cryptography.x509.oid.ExtensionOID import KEY_USAGE [as 別名]
def key_usage(self):
"""The :py:class:`~django_ca.extensions.KeyUsage` extension, or ``None`` if it doesn't exist."""
ext = self.get_x509_extension(ExtensionOID.KEY_USAGE)
if ext is not None:
return KeyUsage(ext)