> ## Documentation Index
> Fetch the complete documentation index at: https://docs.futurex.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Configure Dogtag Certificate System

> Step-by-step guide to install and configure Dogtag CA on Fedora Linux, integrating with CryptoHub for secure key storage.

This section shows you how to install Dogtag Certificate System on Fedora Linux 28. The example demonstrates the installation of a CA subsystem by using a self-signed CA signing certificate, with the certificates and their corresponding keys securely stored in CryptoHub.

## Install the Dogtag packages

<Steps>
  <Step>
    Install the Dogtag packages by using the following command:

    ```shell expandable lines wrap title="Shell" theme={null}
    sudo dnf install pki-ca pki-kra 389-ds-base
    ```
  </Step>
</Steps>

## Create the Directory Server instance

The Dogtag CA and KRA subsystems use a 389 Directory Server as an internal database. Perform the following steps to create the Directory Server instance for the Dogtag Internal DB:

<Steps>
  <Step>
    Run the following command to log in as the root user:

    ```shell expandable lines wrap title="Shell" theme={null}
    sudo su
    ```
  </Step>

  <Step>
    To set a FQDN (fully qualified domain name) as the hostname for your Fedora 28 system, edit the `/etc/hosts` file as follows:

    ```shell expandable lines wrap title="Shell" theme={null}
    127.0.0.1   pki.example.com
    ::1         pki.example.com
    ```

    <Note>
      You can set any valid FQDN,  not just`pki.example.com`.
    </Note>

    You must also run the following command to update the hostname in the `/etc/hostname` file.

    ```shell expandable lines wrap title="Shell" theme={null}
    hostnamectl set-hostname pki.example.com
    ```
  </Step>

  <Step>
    Create a directory for storing the 389 Directory Server configuration file:

    ```shell expandable lines wrap title="Shell" theme={null}
    mkdir -p /etc/389-ds
    ```
  </Step>

  <Step>
    Create a configuration file named **setup.inf** in the `/etc/389-ds` directory with the **\[General]** and **\[slapd]** sections configured as follows:

    ```shell expandable lines wrap title="Shell" theme={null}
    [General] 
    FullMachineName= pki.example.com
    SuiteSpotUserID= nobody
    SuiteSpotGroup= nobody

    [slapd] 
    ServerPort= 389
    ServerIdentifier= pki-tomcat
    Suffix= dc=example,dc=com
    RootDN= cn=Directory Manager
    RootDNPwd= Password
    ```
  </Step>

  <Step>
    Run the directory server installation script, selecting the defaults or customizing as desired:

    ```shell expandable lines wrap title="Shell" theme={null}
    setup-ds.pl --silent --file=/etc/389-ds/setup.inf
    ```
  </Step>
</Steps>

## Create a subsystem instance

The next step in the process is to run the **pkispawn** script to create and configure a subsystem instance.

The **pkispawn** command line tool installs and configures a new PKI instance. It eliminates the need for separate installation and configuration steps, and may be run either interactively, as a batch process, or a combination of both (batch process with prompts for passwords). Refer to the **pkispawn** man page for detailed information about all supported options by running **man pkispawn**.

The **pkispawn** command reads in its default installation and configuration values from a plain text configuration file (`/etc/pki/default.cfg`). This file consists of name=value pairs divided into `[DEFAULT]`, `[Tomcat]`, `[CA]`, `[KRA]`, `[OCSP]`, `[TKS]`, and `[TPS]` sections.

<Note>
  We strongly recommend that you read the full documentation to understand the purpose of every parameter in the `/etc/pki/default.cfg` file. This enables you to customize your PKI environment to your specific needs.
</Note>

To spawn a subsystem that uses an HSM, Dogtag recommends creating an override configuration file that contains only the parameters necessary for using the CryptoHub as its token. Any parameter settings in this file override the parameter settings in the `default.cfg` file.

You can spawn any of the various Dogtag PKI subsystems (CA, KRA, OCSP, TKS, TPS) to use the CryptoHub, but this integration guide focuses on the Certificate Authority (CA) for brevity.

Perform the following tasks:

1. Prepare an override configuration file with the required HSM parameters.
2. Run the **pkispawn** utility.
3. View the keys and certificates that Dogtag created in the CryptoHub.
4. Import the CA administrator PKCS #12 file into the browser.
5. Access the new CA subsystem in the browser.

### Prepare a configuration file

Perform the following steps to prepare an override configuration file with the required HSM parameters:

<Steps>
  <Step>
    Create the override configuration file for the CA subsystem.

    ```shell expandable lines wrap title="Shell" theme={null}
    sudo vim ca.cfg
    ```
  </Step>

  <Step>
    The following is an example override file that can be used for spawning a CA subsystem with the CryptoHub :

    <Note>
      All values contained within angle brackets need to be set to a specific value by the user. All other values should be set exactly as shown.
    </Note>

    <Note>
      The `pkidspassword` value must match the password set for the directory manager when 389 Directory Server was installed.
    </Note>

    <Note>
      The `pkitokenpassword` value must be set to the CryptoHub identity password configured inside the `<CRYPTO-OPR-PASS>` tag in the `fxpkcs11.cfg` file.
    </Note>

    ```text expandable lines wrap title="Text" theme={null}
    [DEFAULT]
    ##########################
    # Provide HSM parameters #
    ##########################
    pki_hsm_enable=True
    pki_hsm_libfile=<path_to_fxpkcs11_libfile>
    pki_hsm_modulename=FxPKCS11
    pki_token_name=Futurex
    pki_token_password=<hsm_identity_password>

    ########################################
    # Provide PKI-specific HSM token names #
    ########################################
    pki_audit_signing_token=Futurex
    pki_ssl_server_token=Futurex
    pki_subsystem_token=Futurex

    ##################################
    # Provide PKI-specific passwords #
    ##################################
    pki_admin_password=<pki_admin_password>
    pki_client_pkcs12_password=<pki_client_pkcs12_password>
    pki_ds_password=<pki_ds_password>

    #####################################
    # Provide non-CA-specific passwords #
    #####################################
    pki_client_database_password=<pki_client_database_password>

    [CA]
    #######################################
    # Provide CA-specific HSM token names #
    #######################################
    pki_ca_signing_token=Futurex
    pki_ocsp_signing_token=Futurex
    ```
  </Step>

  <Step>
    After you have finished editing, save the file.
  </Step>
</Steps>

### Run the pkispawn utility

Perform the following steps to run the pkispawn utility:

<Steps>
  <Step>
    In a terminal, run the following command to deploy a CA subsystem using the CryptoHub.

    <Note>
      The full path to the `ca.cfg` file is required if you are not running the command from the directory where the `ca.cfg` file is saved.
    </Note>

    ```shell expandable lines wrap title="Shell" theme={null}
    sudo pkispawn -f ca.cfg -s CA -vvv
    ```

    <Note>
      You will most likely see a warning message about manually adding a module while p11-kit is enabled. You can disregard this warning and press Enter to continue.
    </Note>
  </Step>

  <Step>
    If the deployment is successful, an installation summary similar to the following will be presented after the command completes:

    ```shell expandable lines wrap title="Shell" theme={null}
    ==========================================================================
                                INSTALLATION SUMMARY
    ==========================================================================

    Administrator's username:             caadmin
    Administrator's PKCS #12 file:
        /root/.dogtag/pki-tomcat/ca_admin_cert.p12

    To check the status of the subsystem:
        systemctl status pki-tomcatd@pki-tomcat.service

    To restart the subsystem:
        systemctl restart pki-tomcatd@pki-tomcat.service

    The URL for the subsystem is:
        https://pki.example.com:8443/ca

    PKI instances will be enabled upon system boot

    ==========================================================================
    ```

    <Note>
      If the pkispawn command fails, you need to run the following command to delete the subsystem instance that was only partially created before re-attempting to run pkispawn.
    </Note>

    ```shell expandable lines wrap title="Shell" theme={null}
    sudo pkidestroy -s CA -i pki-tomcat
    ```
  </Step>
</Steps>

### View the keys and certificates

To view the keys and certificates that Dogtag created on the CryptoHub , use the **PKCS11Manager** utility packaged with the Futurex PKCS #11 module. Perform the following steps:

<Steps>
  <Step>
    In a terminal, navigate to the directory where the FXPKCS11 module is installed (`/usr/local/bin/fxpkcs11`) and run **PKCS11Manager** by using the following command:

    ```shell expandable lines wrap title="Shell" theme={null}
    ./PKCS11Manager
    ```

    <Check>
      This presents the following main menu:

      ```shell expandable lines wrap title="Shell" theme={null}
      Main Menu

      1. Print Library/Token Info

      2. Login
      3. Logout

      4. Generate Key

      5. Find Objects
      6. Modify Objects
      7. Delete Objects

      8. Generate Random Data

      9. Sign Data
      10. Verify Data

      11. Wrap Key
      12. Unwrap Key

      13. Import public key

      0. Exit
      ```
    </Check>
  </Step>

  <Step>
    Enter `1` to find all objects, and select the **Enter** key.
  </Step>

  <Step>
    Enter `2` to log in, and select the **Enter** key.
  </Step>

  <Step>
    Enter the password of the identity that is defined in the **FXPKCS11** configuration file, and select the **Enter** key. If successful, you receive confirmation that you are logged in.
  </Step>

  <Step>
    Enter `5` to find objects, and select the **Enter** key.
  </Step>

  <Step>
    Enter `1` to find all objects, and select the **Enter** key. Information prints for all keys and certificates that the connecting identity has access to.

    <Note>
      Dogtag PKI creates 15 objects in CryptoHub for a CA subsystem deployment.
    </Note>
  </Step>
</Steps>

### Import the PKCS #12 file

<Note>
  The following steps use a Firefox web browser. The steps might vary when using a different browser, but the overall process is the same.
</Note>

Perform the following steps to import the CA administrator PKCS #12 file into the browser:

<Steps>
  <Step>
    In Firefox, go to **Preferences** > **Privacy & Security** > **Certificates** and select **\[ View Certificates ]**.
  </Step>

  <Step>
    Under the **Your Certificates** tab, select **\[ Import ]** to import the CA Administrator PKCS #12 file (for example, `ca_admin_cert.p12`). When it prompts for a password, enter the value that was configured for the `pki_client_pkcs12_password` define in the `ca.cfg` file.

    <Note>
      The location of the `caadmincert.p12` file is in the installation summary for the CA subsystem deployment.
    </Note>
  </Step>
</Steps>

### Access the CA subsystem

Perform the following steps to access the new CA subsystem in the browser:

<Steps>
  <Step>
    Access the Dogtag Certificate System subsystem console by going to the following URL:

    ```none expandable lines wrap title="None" theme={null}
    https://:8443/pki/ui/
    ```
  </Step>
</Steps>

<Note>
  When submitting Certificate Signing Requests (CSRs) in Dogtag Certificate System, you must use both the Common Name and UID fields. If you submit a request with only the Common Name field completed, the request fails, and you receive an error stating that the Subject Name does not match.
</Note>

<Iframe code="<fully qualified domain name>" />

This completes the instructions for the Dogtag Certificate System integration with the Futurex CryptoHub. All CA subsystem keys are secured within CryptoHub and available to the Dogtag Certificate System when you need to use them.
