NPKD Installation with Wildfly 11

This NPKD Installation guide covers how to install NPKD with JBoss Wildfly 11:

Set up JBoss

  1. Edit /opt/primekey/jboss-npkd/bin/standalone.conf to increase the memory and force using 2048-bit DH keys

    1. Increase the memory by setting JAVA_OPTS variable to

      JAVA_OPTS="-Xms2048m -Xmx2048m -Djava.net.preferIPv4Stack=true"
    2. Force use of 2048-bit DH keys in order to mitigate https://weakdh.org/ by adding the following line:

      JAVA_OPTS="$JAVA_OPTS -Djdk.tls.ephemeralDHKeySize=2048"
  2. If an HSM is to be used, add the following patches to all JBoss instances in the file /opt/primekey/jboss/modules/system/layers/base/sun/jdk/main/module.xml after all paths.
    (For an example module.xml file, see Appendix C).

        <path name="sun/security/x509"/>
        <path name="sun/security/pkcs11"/>
        <path name="sun/security/pkcs11/wrapper"/>
  3. Add the MariaDB Java Client mariadb-java-client-1.5.2.jar into JBoss directory

    Run as primekey

    cp mariadb-java-client-1.5.2.jar /opt/primekey/jboss-npkd/standalone/deployments/
    ln -s /opt/primekey/jboss-npkd/standalone/deployments/mariadb-java-client-1.5.2.jar /opt/primekey/jboss-npkd/standalone/deployments/mariadb-java-client.jar
  4. Copy the keystore file as /opt/primekey/jboss/standalone/configuration/keystore/keystore.jks and the trust store as /opt/primekey/jboss/standalone/configuration/keystore/truststore.jks. Use the same keystore and truststore of existing EJBCA installation

    mkdir /opt/primekey/jboss-npkd/standalone/configuration/keystore
    ln -s /opt/primekey/jboss-ejbca/standalone/configuration/keystore/truststore.jks /opt/primekey/jboss-npkd/standalone/configuration/keystore/truststore.jks
    ln -s /opt/primekey/jboss-ejbca/standalone/configuration/keystore/keystore.jks /opt/primekey/jboss-npkd/standalone/configuration/keystore/keystore.jks

Configure JBoss

  1. Start JBoss

    sudo systemctl restart jboss-npkd
  2. Start JBoss CLI on a different terminal to configure data source:

    /opt/primekey/jboss-npkd/bin/jboss-cli.sh --connect
  3. Add a datasource as follows and make sure to use the right database name, username and password, and the correct date-source name as configured in /opt/primekey/npkd/conf/npkd_deploy.properties:

    Run in JBoss CLI

    data-source add --name=npkdds --driver-name="mariadb-java-client.jar" --connection-url="jdbc:mysql://127.0.0.1:3306/npkddb" --jndi-name="java:/npkdDS" --use-ccm=true --driver-class="org.mariadb.jdbc.Driver" --user-name="npkd" --password="npkd" --validate-on-match=true --background-validation=false --prepared-statements-cache-size=50 --share-prepared-statements=true --min-pool-size=5 --max-pool-size=150 --pool-prefill=true --transaction-isolation=TRANSACTION_READ_COMMITTED --check-valid-connection-sql="select 1;"
    :reload

    If the data source was configured successfully, the output will be similar to:

    "outcome" => "success"
  4. Configure logging

    /subsystem=logging/logger=se.primekey.npkd:add
    /subsystem=logging/logger=se.primekey.npkd:write-attribute(name=level, value=INFO)
    /subsystem=logging/logger=org.cesecore:add
    /subsystem=logging/logger=org.cesecore:write-attribute(name=level, value=INFO)
  5. Remove existing TLS and HTTP configuration

    /subsystem=undertow/server=default-server/http-listener=default:remove
    /subsystem=undertow/server=default-server/https-listener=https:remove
    /socket-binding-group=standard-sockets/socket-binding=http:remove
    /socket-binding-group=standard-sockets/socket-binding=https:remove
    :reload
  6. Configure WildFly Remoting

    /subsystem=remoting/http-connector=http-remoting-connector:remove
    /subsystem=remoting/http-connector=http-remoting-connector:add(connector-ref="remoting",security-realm="ApplicationRealm")
    /socket-binding-group=standard-sockets/socket-binding=remoting:add(port="4447")
    /subsystem=undertow/server=default-server/http-listener=remoting:add(socket-binding=remoting)
    :reload
  7. Configure TLS

    /interface=http:add(inet-address="0.0.0.0")
    /interface=httpspub:add(inet-address="0.0.0.0")
    /interface=httpspriv:add(inet-address="0.0.0.0")
    /socket-binding-group=standard-sockets/socket-binding=http:add(port="8080",interface="http")
    /subsystem=undertow/server=default-server/http-listener=http:add(socket-binding=http)
    :reload
  8. Configure identities and socket bindings:

    /core-service=management/security-realm=SSLRealm:add()
    /core-service=management/security-realm=SSLRealm/server-identity=ssl:add(keystore-path="${jboss.server.config.dir}/keystore/keystore.jks", keystore-password="serverpwd", alias="localhost")
    /core-service=management/security-realm=SSLRealm/authentication=truststore:add(keystore-path="${jboss.server.config.dir}/keystore/truststore.jks", keystore-password="changeit")
    /socket-binding-group=standard-sockets/socket-binding=httpspriv:add(port="8443",interface="httpspriv")
    /socket-binding-group=standard-sockets/socket-binding=httpspub:add(port="8442", interface="httpspub")
    /subsystem=undertow/server=default-server/http-listener=http:write-attribute(name=redirect-socket, value="httpspriv")
  9. Exit the JBoss CLI:

    exit
  10. Restart JBoss

    sudo systemctl restart jboss-npkd
  11. Connect to the JBoss CLI again to continue configuration

    /opt/primekey/jboss-npkd/bin/jboss-cli.sh --connect
  12. Add socket bindings

    /subsystem=undertow/server=default-server/https-listener=httpspriv:add(socket-binding=httpspriv, security-realm="SSLRealm", verify-client=REQUIRED)
    /subsystem=undertow/server=default-server/https-listener=httpspriv:write-attribute(name=max-parameters, value="2048")
    /subsystem=undertow/server=default-server/https-listener=httpspub:add(socket-binding=httpspub, security-realm="SSLRealm")
    /subsystem=undertow/server=default-server/https-listener=httpspub:write-attribute(name=max-parameters, value="2048")
    :reload
  13. Finalize Wildfly configuration with some important items:

    /system-property=org.apache.tomcat.util.buf.UDecoder.ALLOW_ENCODED_SLASH:add(value=true)
    /system-property=org.apache.catalina.connector.CoyoteAdapter.ALLOW_BACKSLASH:add(value=true)
    /system-property=org.apache.catalina.connector.URI_ENCODING:add(value="UTF-8")
    /system-property=org.apache.catalina.connector.USE_BODY_ENCODING_FOR_QUERY_STRING:add(value=true)
    /subsystem=webservices:write-attribute(name=wsdl-host, value=jbossws.undefined.host)
    /subsystem=webservices:write-attribute(name=modify-wsdl-address, value=true)
    :reload
  14. Since some transactions (like full listing download or rerunning revocation checks) can take a lot of time, default-timeout should be increased from default value 300 seconds. Recommended is half an hour.

    /subsystem=transactions:write-attribute(name="default-timeout", value="1800")
  15. Exit the CLI

    exit
  16. Restart JBoss

    sudo systemctl restart jboss-npkd

Deploy NPKD

  1. Deploy NPKD:

    cd /opt/primekey/npkd
    ant deploy-ear

    Make sure that JBoss deployed without errors

  2. Restart Jboss:

    sudo systemctl restart jboss-npkd
  3. Verify that NPKD has deployed correctly:

    tail -n20 /opt/primekey/jboss/standalone/log/server.log | grep "npkd.ear"
  4. Install your SuperAdmin certificate in the web browser.
  5. Connect to NPKD in the web browser using the URL: https://localhost:8443/npkd

  6. The first time you login to the system, the following message is shown: "Access Control Module is NOT initialized. Error accessing NPKD <SUBJECT DN> is not authorized to access the NPKD GUI". Click Register.
  7. Confirm by clicking Yes in the pop-up window.
  8. Re-load/refresh the browser.