本文整理汇总了Python中cryptography.x509.PrecertPoison方法的典型用法代码示例。如果您正苦于以下问题:Python x509.PrecertPoison方法的具体用法?Python x509.PrecertPoison怎么用?Python x509.PrecertPoison使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类cryptography.x509
的用法示例。
在下文中一共展示了x509.PrecertPoison方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _create_x509_extension
# 需要导入模块: from cryptography import x509 [as 别名]
# 或者: from cryptography.x509 import PrecertPoison [as 别名]
def _create_x509_extension(self, handlers, extension):
if isinstance(extension.value, x509.UnrecognizedExtension):
value = _encode_asn1_str_gc(self, extension.value.value)
return self._create_raw_x509_extension(extension, value)
elif isinstance(extension.value, x509.TLSFeature):
asn1 = encode_der(
SEQUENCE,
*[
encode_der(INTEGER, encode_der_integer(x.value))
for x in extension.value
]
)
value = _encode_asn1_str_gc(self, asn1)
return self._create_raw_x509_extension(extension, value)
elif isinstance(extension.value, x509.PrecertPoison):
value = _encode_asn1_str_gc(self, encode_der(NULL))
return self._create_raw_x509_extension(extension, value)
else:
try:
encode = handlers[extension.oid]
except KeyError:
raise NotImplementedError(
'Extension not supported: {}'.format(extension.oid)
)
ext_struct = encode(self, extension.value)
nid = self._lib.OBJ_txt2nid(
extension.oid.dotted_string.encode("ascii")
)
backend.openssl_assert(nid != self._lib.NID_undef)
return self._lib.X509V3_EXT_i2d(
nid, 1 if extension.critical else 0, ext_struct
)
示例2: __init__
# 需要导入模块: from cryptography import x509 [as 别名]
# 或者: from cryptography.x509 import PrecertPoison [as 别名]
def __init__(self, value=None):
super().__init__(value=value)
if self.critical is not True:
raise ValueError('PrecertPoison must always be marked as critical')
示例3: test_critical
# 需要导入模块: from cryptography import x509 [as 别名]
# 或者: from cryptography.x509 import PrecertPoison [as 别名]
def test_critical(self):
with self.assertRaisesRegex(ValueError, r'^PrecertPoison must always be marked as critical$'):
PrecertPoison({'critical': False})
示例4: _create_x509_extension
# 需要导入模块: from cryptography import x509 [as 别名]
# 或者: from cryptography.x509 import PrecertPoison [as 别名]
def _create_x509_extension(self, handlers, extension):
if isinstance(extension.value, x509.UnrecognizedExtension):
value = _encode_asn1_str_gc(self, extension.value.value)
return self._create_raw_x509_extension(extension, value)
elif isinstance(extension.value, x509.TLSFeature):
asn1 = _Integers([x.value for x in extension.value]).dump()
value = _encode_asn1_str_gc(self, asn1)
return self._create_raw_x509_extension(extension, value)
elif isinstance(extension.value, x509.PrecertPoison):
asn1 = asn1crypto.core.Null().dump()
value = _encode_asn1_str_gc(self, asn1)
return self._create_raw_x509_extension(extension, value)
else:
try:
encode = handlers[extension.oid]
except KeyError:
raise NotImplementedError(
'Extension not supported: {}'.format(extension.oid)
)
ext_struct = encode(self, extension.value)
nid = self._lib.OBJ_txt2nid(
extension.oid.dotted_string.encode("ascii")
)
backend.openssl_assert(nid != self._lib.NID_undef)
return self._lib.X509V3_EXT_i2d(
nid, 1 if extension.critical else 0, ext_struct
)