pki.models.extensionΒΆ
Module that contains X.509 Extension Models.
ClassesΒΆ
AttributeTypeAndValue Model. |
|
GeneralNameRFC822Name Model. |
|
GeneralNameDNSName Model. |
|
GeneralNameDirectoryName Model. |
|
GeneralNameUniformResourceIdentifier Model. |
|
GeneralNameIpAddress Model. |
|
GeneralNameRegisteredId Model. |
|
GeneralNameOtherName Model. |
|
Abstract Base Class of Extension Models. |
|
Represents the BasicConstraints extension in X.509 certificates. |
|
Represents the KeyUsage extension in X.509 certificates. |
|
Represents a collection of general names as per RFC5280. |
|
IssuerAlternativeNameExtension Model. |
|
Represents the SubjectAlternativeName extension in X.509 certificates. |
|
Represents the PolicyConstraints extension in X.509 certificates. |
Module ContentsΒΆ
- class pki.models.extension.AttributeTypeAndValue(*args, **kwargs)[source]ΒΆ
Bases:
django.db.models.ModelAttributeTypeAndValue Model.
Used for subject entries as well as the GeneralNameDirectoryName entries within the SubjectAlternativeName and IssuerAlternativeName.
See RFC5280 for more information.
- __str__()[source]ΒΆ
Returns a string representation of the attribute type and value.
- Return type:
str
- class pki.models.extension.GeneralNameRFC822Name(*args, **kwargs)[source]ΒΆ
Bases:
util.db.OrphanDeletionMixin,django.db.models.ModelGeneralNameRFC822Name Model.
Entries of either SubjectAlternativeNames or IssuerAlternativeNames.
See RFC5280 for more information.
- class pki.models.extension.GeneralNameDNSName(*args, **kwargs)[source]ΒΆ
Bases:
util.db.OrphanDeletionMixin,django.db.models.ModelGeneralNameDNSName Model.
See RFC5280 for more information.
- class pki.models.extension.GeneralNameDirectoryName(*args, **kwargs)[source]ΒΆ
Bases:
util.db.OrphanDeletionMixin,django.db.models.ModelGeneralNameDirectoryName Model.
Entries of either SubjectAlternativeNames or IssuerAlternativeNames.
See RFC5280 for more information.
- class pki.models.extension.GeneralNameUniformResourceIdentifier(*args, **kwargs)[source]ΒΆ
Bases:
util.db.OrphanDeletionMixin,django.db.models.ModelGeneralNameUniformResourceIdentifier Model.
Entries of either SubjectAlternativeNames or IssuerAlternativeNames.
See RFC5280 for more information.
- class pki.models.extension.GeneralNameIpAddress(*args, **kwargs)[source]ΒΆ
Bases:
util.db.OrphanDeletionMixin,django.db.models.ModelGeneralNameIpAddress Model.
Entries of either SubjectAlternativeNames or IssuerAlternativeNames.
See RFC5280 for more information.
- class pki.models.extension.GeneralNameRegisteredId(*args, **kwargs)[source]ΒΆ
Bases:
util.db.OrphanDeletionMixin,django.db.models.ModelGeneralNameRegisteredId Model.
Entries of either SubjectAlternativeNames or IssuerAlternativeNames.
See RFC5280 for more information.
- class pki.models.extension.GeneralNameOtherName(*args, **kwargs)[source]ΒΆ
Bases:
util.db.OrphanDeletionMixin,django.db.models.ModelGeneralNameOtherName Model.
Entries of either SubjectAlternativeNames or IssuerAlternativeNames.
See RFC5280 for more information.
- class pki.models.extension.CertificateExtension(*args, **kwargs)[source]ΒΆ
Bases:
util.db.OrphanDeletionMixinAbstract Base Class of Extension Models.
Due to a Metaclass conflict, this class is not derived from abc.ABC on purpose. # TODO: check if this can be rectified
- classmethod save_from_crypto_extensions(extension)[source]ΒΆ
- Abstractmethod:
- Parameters:
extension (cryptography.x509.Extension[T])
- Return type:
CertificateExtension | None
Stores the extension in the database.
Meant to be called within an atomic transaction while storing a certificate.
- Parameters:
extension (x509.Extension) β The X.509 extension object.
- Returns:
The instance of the saved extension.
- Return type:
- classmethod delete_if_orphaned(instance)[source]ΒΆ
Removes the Extension instance if no longer referenced.
Since all extension classes are only referenced by the Certificate model with on_delete=models.PROTECT, we can rely on the database protection to remove the instance if it is no longer referenced. This saves an extra query to check if the βcertificatesβ reverse relation still exists.
- Parameters:
instance (util.db.OrphanDeletionMixin | None)
- Return type:
None
- class pki.models.extension.BasicConstraintsExtension(*args, **kwargs)[source]ΒΆ
Bases:
CertificateExtension,django.db.models.ModelRepresents the BasicConstraints extension in X.509 certificates.
This extension indicates whether a certificate is a CA and its path length.
- classmethod save_from_crypto_extensions(crypto_basic_constraints_extension)[source]ΒΆ
Stores the BasicConstraintsExtension in the database.
- Parameters:
crypto_basic_constraints_extension (x509.Extension) β The X.509 extension containing BasicConstraints.
- Returns:
The instance of the saved extension.
- Return type:
- class pki.models.extension.KeyUsageExtension(*args, **kwargs)[source]ΒΆ
Bases:
CertificateExtension,django.db.models.ModelRepresents the KeyUsage extension in X.509 certificates.
Specifies the permitted usage of the certificateβs public key.
- classmethod save_from_crypto_extensions(crypto_basic_constraints_extension)[source]ΒΆ
Stores the KeyUsage extension in the database.
- Parameters:
crypto_basic_constraints_extension (x509.Extension) β The X.509 extension containing KeyUsage.
- Returns:
The instance of the saved extension.
- Return type:
- class pki.models.extension.GeneralNamesModel(*args, **kwargs)[source]ΒΆ
Bases:
util.db.OrphanDeletionMixin,util.db.CustomDeleteActionModelRepresents a collection of general names as per RFC5280.
Used for both SubjectAlternativeName and IssuerAlternativeName extensions.
- _save_rfc822_name(entry)[source]ΒΆ
- Parameters:
entry (cryptography.x509.RFC822Name)
- Return type:
None
- _save_uri(entry)[source]ΒΆ
- Parameters:
entry (cryptography.x509.UniformResourceIdentifier)
- Return type:
None
- _save_registered_id(entry)[source]ΒΆ
- Parameters:
entry (cryptography.x509.RegisteredID)
- Return type:
None
- _save_directory_name(entry)[source]ΒΆ
- Parameters:
entry (cryptography.x509.DirectoryName)
- Return type:
None
- class pki.models.extension.IssuerAlternativeNameExtension(*args, **kwargs)[source]ΒΆ
Bases:
CertificateExtension,util.db.CustomDeleteActionModelIssuerAlternativeNameExtension Model.
See RFC5280 for more information.
- __str__()[source]ΒΆ
Returns a string representation of the IssuerAlternativeName extension.
- Return type:
str
- classmethod save_from_crypto_extensions(extension)[source]ΒΆ
Stores the IssuerAlternativeNameExtension in the database.
Meant to be called within an atomic transaction while storing a certificate.
- Parameters:
extension (x509.Extension) β The x509.Extension object that contains all extensions of the certificate.
- Returns:
The instance of the saved IssuerAlternativeNameExtension.
- Return type:
trustpoint.pki.models.IssuerAlternativeNameExtension
- class pki.models.extension.SubjectAlternativeNameExtension(*args, **kwargs)[source]ΒΆ
Bases:
CertificateExtension,util.db.CustomDeleteActionModelRepresents the SubjectAlternativeName extension in X.509 certificates.
Stores alternative names for the certificateβs subject.
- __str__()[source]ΒΆ
Returns a string representation of the SubjectAlternativeName extension.
- Return type:
str
- class pki.models.extension.PolicyConstraintsExtension(*args, **kwargs)[source]ΒΆ
Bases:
CertificateExtension,django.db.models.ModelRepresents the PolicyConstraints extension in X.509 certificates.
This extension specifies whether an explicit policy is required and whether policy mapping is inhibited.
- objects: django.db.models.Manager[PolicyConstraintsExtension][source]ΒΆ
- __str__()[source]ΒΆ
Returns a string representation of the PolicyConstraintsExtension.
- Return type:
str