> ## 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.

# Using OpenSSL and Java

> Instructions and best practices for avoiding conflicts when using OpenSSL and Java with the same PKCS#11 library.

## Working with OpenSSL and Java

There is a known issue when OpenSSL providers and Java both reference the same `libfxpkcs11.so` file. If both environments use the same file, it can cause either Java or any OpenSSL PKCS#11 HSM operations to fail.

If OpenSSL and Java will be installed on the same device, to avoid the issue, we recommend performing the following steps:

<Steps>
  <Step>
    Create separate directories for Java and OpenSSL, for example:

    ```none expandable lines wrap title="None" theme={null}
    /usr/local/lib/fxpkcs11/openssl/libfxpkcs11.so
    /usr/local/lib/fxpkcs11/java/libfxpkcs11.so 
    ```
  </Step>

  <Step>
    Place a distinct copy of `libfxpkcs11.so` into each directory
  </Step>

  <Step>
    Configure OpenSSL and Java to point to their respective copies

    * For Java, edit the `library` line in `pkcs11.cfg` file. If our recommendation was followed, the file should be located at `/usr/local/etc/`
    * For PKCS11 Provider, edit the `pkcs11-module-path`line in `openssl.cnf` file.
      If the user chose to edit the global file, run the command to find where the global OpenSSL file is located

    <CodeblockTabs indent="1">
      ```shell expandable lines wrap title="Shell" theme={null}
      openssl version -d
      ```
    </CodeblockTabs>

    <Paragraph indent="1">
      If the user chose to edit a copy of the global file, edit the file where the user chose to place it, and export the envrionment variable
    </Paragraph>

    <CodeblockTabs indent="1">
      ```shell expandable lines wrap title="Shell" theme={null}
      export OPENSSL_CONF=/path/to/openssl.cnf
      ```
    </CodeblockTabs>
  </Step>
</Steps>
