django_ca.extensions
- X509 extensions¶
This module provides some small helper functions for handling extensions.
- django_ca.extensions.parse_extension(key, value)[source]¶
Parse a serialized extension into a cryptography object.
This function is used by django_ca.profiles - Certificate profiles to parse configured extensions into standard cryptography extensions. If you need to parse a similar object, use this function.
The value is usually a
dict
as described in profiles but for convenience, may also be aExtension
, in which case the extension is returned unchanged. If you pass aExtensionType
, an extension with the default critical value is returned.>>> parse_extension("key_usage", {'critical': True, 'value': ['keyCertSign']}) <Extension(..., critical=True, value=<KeyUsage(... key_cert_sign=True, ...)>)>
- Parameters
- keystr
The key is the extension key used in the dictionary to name the extension, it must match one of the keys in
EXTENSION_KEYS
.- valuedict,
ExtensionType
orExtension
The value that describes the extension. See Profiles for more information.
- django_ca.extensions.serialize_extension(extension)[source]¶
Serialize an extension to a dictionary.
This is the inverse of
parse_extension()
and is used to serialize extension information for API calls in the admin interface.