pki.forms.truststores ===================== .. py:module:: pki.forms.truststores .. autoapi-nested-parse:: Django forms for truststore configuration and management. Module Contents --------------- .. py:class:: TruststoreAddForm(data=None, files=None, auto_id='id_%s', prefix=None, initial=None, error_class=ErrorList, label_suffix=None, empty_permitted=False, field_order=None, use_required_attribute=None, renderer=None, bound_field_class=None) Bases: :py:obj:`django.forms.Form` Form for adding a new truststore. This form handles the creation of a truststore by validating the unique name, intended usage, and uploaded file. It ensures the unique name is not already used and validates the truststore file content before saving. .. attribute:: unique_name A unique name for the truststore. :type: CharField .. attribute:: intended_usage Specifies the intended usage of the truststore. :type: ChoiceField .. attribute:: trust_store_file The PEM or PKCS#7 file to be uploaded. :type: FileField .. py:attribute:: unique_name .. py:attribute:: intended_usage .. py:attribute:: trust_store_file .. py:method:: clean_unique_name() Validates the uniqueness of the truststore name. :raises ValidationError: If the name is already used by an existing truststore. .. py:method:: clean() Cleans and validates the form data. Ensures the uploaded file can be read and validates the unique name and intended usage fields. If validation passes, initializes and saves the truststore. :raises ValidationError: If the truststore file cannot be read, the unique name :raises is not unique, or an unexpected error occurs during initialization.: .. py:method:: save_trust_store(unique_name, intended_usage, certificates) :staticmethod: Save all certificates of a truststore. .. py:function:: validate_and_create_ca_chain(certificates, intended_usage) Validate certificate chain and create keyless CA models for intermediates. :param certificates: List of certificates in the truststore (order: leaf to root or root to leaf) :param intended_usage: The intended usage of the truststore :returns: The issuing CA (parent of the leaf certificate), or None if not ISSUING_CA_CHAIN :raises ValidationError: If the chain is invalid or incomplete for ISSUING_CA_CHAIN usage .. py:class:: TruststoreDownloadForm(data=None, files=None, auto_id='id_%s', prefix=None, initial=None, error_class=ErrorList, label_suffix=None, empty_permitted=False, field_order=None, use_required_attribute=None, renderer=None, bound_field_class=None) Bases: :py:obj:`django.forms.Form` Form for downloading truststores in various formats. This form provides options to customize the download of truststores, allowing users to specify the container type, inclusion of certificate chains, and the file format. It ensures flexibility in exporting truststores for various use cases and environments. .. attribute:: cert_file_container Specifies the container type for the truststore. - `single_file`: The entire truststore in a single file. - `zip`: Certificates as separate files in a `.zip` archive. - `tar_gz`: Certificates as separate files in a `.tar.gz` archive. :type: ChoiceField .. attribute:: cert_chain_incl Specifies whether to include certificate chains. - `cert_only`: Only the selected certificates. - `chain_incl`: Include certificate chains. :type: ChoiceField .. attribute:: cert_file_format Specifies the file format for the truststore. - `pem`: PEM format (.pem, .crt, .ca-bundle). - `der`: DER format (.der, .cer). - `pkcs7_pem`: PKCS#7 format in PEM encoding (.p7b, .p7c, .keystore). - `pkcs7_der`: PKCS#7 format in DER encoding (.p7b, .p7c, .keystore). :type: ChoiceField .. py:attribute:: cert_file_container .. py:attribute:: cert_chain_incl .. py:attribute:: cert_file_format