Search code examples
javajbosswildfly

wildfly 21 -- add bouncy castle provider without changing JDK configuration


I tried creating a module with the provider jar This is the module:

    <?xml version="1.0" encoding="UTF-8"?>
    <module xmlns="urn:jboss:module:1.3" name="com.acme.bouncy">
        <resources>
            <resource-root path="bcprovider.jar"/>
        </resources>
        <dependencies>
            <module name="javax.api"/>
            <module name="javax.transaction.api"/>
        </dependencies>
    </module>

I added the option to change security file to wildfly.conf which adds the provider

JAVA_OPTS="$JAVA_OPTS -Djava.security.properties=/var/opt/acme/bcprops.security"

but I still get this error unless the jar file is added to jre/lib/ext (which I don't want to do):

2023-02-21 03:42:47,014 ERROR [org.jboss.msc.service.fail] (MSC service thread 1-2) MSC000001: Failed to start service org.wildfly.security.credential-store.mastercs: org.jboss.msc.service.StartException in service org.wildfly.security.credential-store.mastercs: WFLYELY00004: Unable to start the service.
    at org.wildfly.extension.elytron.CredentialStoreService.start(CredentialStoreService.java:132)
    at org.jboss.msc.service.ServiceControllerImpl$StartTask.startService(ServiceControllerImpl.java:1739)
    at org.jboss.msc.service.ServiceControllerImpl$StartTask.execute(ServiceControllerImpl.java:1701)
    at org.jboss.msc.service.ServiceControllerImpl$ControllerTask.run(ServiceControllerImpl.java:1559)
    at org.jboss.threads.ContextClassLoaderSavingRunnable.run(ContextClassLoaderSavingRunnable.java:35)
    at org.jboss.threads.EnhancedQueueExecutor.safeRun(EnhancedQueueExecutor.java:1990)
    at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.doRunTask(EnhancedQueueExecutor.java:1486)
    at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1363)
    at java.lang.Thread.run(Thread.java:750)
Caused by: org.wildfly.security.credential.store.CredentialStoreException: ELY09514: Unable to initialize credential store
    at org.wildfly.security.credential.store.impl.KeyStoreCredentialStore.getKeyStoreInstance(KeyStoreCredentialStore.java:953)
    at org.wildfly.security.credential.store.impl.KeyStoreCredentialStore.setupExternalStorage(KeyStoreCredentialStore.java:962)
    at org.wildfly.security.credential.store.impl.KeyStoreCredentialStore.load(KeyStoreCredentialStore.java:841)
    at org.wildfly.security.credential.store.impl.KeyStoreCredentialStore.initialize(KeyStoreCredentialStore.java:223)
    at org.wildfly.security.credential.store.CredentialStore.initialize(CredentialStore.java:160)
    at org.wildfly.extension.elytron.CredentialStoreService.start(CredentialStoreService.java:123)
    ... 8 more
Caused by: java.security.KeyStoreException: BKS not found
    at java.security.KeyStore.getInstance(KeyStore.java:851)
    at org.wildfly.security.credential.store.impl.KeyStoreCredentialStore.getKeyStoreInstance(KeyStoreCredentialStore.java:949)
    ... 13 more
Caused by: java.security.NoSuchAlgorithmException: BKS KeyStore not available
    at sun.security.jca.GetInstance.getInstance(GetInstance.java:159)
    at java.security.Security.getImpl(Security.java:695)
    at java.security.KeyStore.getInstance(KeyStore.java:848)
    ... 14 more

Solution

  • You need to add the Module to the standalone.xml configuration File, so that the Wildfly will load the module. See here: http://www.mastertheboss.com/jbossas/jboss-configuration/configuring-global-modules-and-directories-in-wildfly/?amp=1 section global modules

    In your example it should look like this:

        <subsystem xmlns="urn:jboss:domain:ee:1.0" >            
          <global-modules>
            <module name=com.acme.bouncy" slot="main" />            
          </global-modules> 
        </subsystem>
    

    You could also use the jboss-cli to add the module.

    subsystem=ee/:write-attribute(name=global-modules,value=[{"name" => "com.acme.bouncy","slot" => "main"}])