Creating SmartCardHSMKeyStore Results In Null Pointer Exception

I have a JAVA application which runs in windows and interacts with a Nitro HSM Key. However, when access to a key store is attempted, it results in a null pointer exception.

Setup provider as:

SmartCardHSMProvider p = new de.cardcontact.smartcardhsmprovider.SmartCardHSMProvider();
Security.addProvider(p);

Create the keystore:

KeyStore hsm = KeyStore.getInstance(“SmartCardHSMKeyStore”);

Results in:

Exception in thread “main” java.security.ProviderException: java.lang.reflect.InvocationTargetException
at de.cardcontact.smartcardhsmprovider.SmartCardHSMProvider$SCHSMService.newInstance(SmartCardHSMProvider.java:671)
at sun.security.jca.GetInstance.getInstance(Unknown Source)
at sun.security.jca.GetInstance.getInstance(Unknown Source)
at java.security.Security.getImpl(Unknown Source)
at java.security.KeyStore.getInstance(Unknown Source)
at com.fcs.j2se.loader.Loader.main(Loader.java:139)
Caused by: java.lang.reflect.InvocationTargetException
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
at java.lang.reflect.Constructor.newInstance(Unknown Source)
at de.cardcontact.smartcardhsmprovider.SmartCardHSMProvider$SCHSMService.newInstance(SmartCardHSMProvider.java:666)
… 5 more
Caused by: java.lang.NullPointerException
at java.lang.String.startsWith(Unknown Source)
at java.lang.String.startsWith(Unknown Source)
at opencard.core.terminal.CardTerminalRegistry.cardTerminalForName(CardTerminalRegistry.java:158)
at de.cardcontact.smartcardhsmprovider.SmartCardHSMProvider.cardInserted(SmartCardHSMProvider.java:560)
at opencard.core.event.EventGenerator.createEventsForPresentCards(EventGenerator.java:140)
at de.cardcontact.smartcardhsmprovider.SmartCardHSMProvider.checkCardState(SmartCardHSMProvider.java:428)
at de.cardcontact.smartcardhsmprovider.SmartCardHSMProvider.getSmartCardHSMCardService(SmartCardHSMProvider.java:412)
at de.cardcontact.smartcardhsmprovider.SmartCardHSMKeyStore.(SmartCardHSMKeyStore.java:85)
… 10 more

If the following code is run:

    CardTerminalRegistry r = CardTerminalRegistry.getRegistry();
    Enumeration<CardTerminal> v = r.getCardTerminals();
    while (v.hasMoreElements())
    {
        CardTerminal c = (CardTerminal)v.nextElement();
        System.out.println("Card Name = " + c.getName());
    }

The output is:

Card Name = Nitrokey Nitrokey HSM 0

Which matches with slot 0:

C:\Program Files\OpenSC Project\OpenSC\tools>pkcs11-tool.exe --list-slots
Available slots:
Slot 0 (0x0): Nitrokey Nitrokey HSM 0
token label : SmartCard-HSM (UserPIN)
token manufacturer : www.CardContact.de
token model : PKCS#15 emulated
token flags : login required, rng, token initialized, PIN initialized
hardware version : 24.13
firmware version : 3.3
serial num : DENK0102953
pin min/max : 6/15

It appears I have some configuration missing to tie the key store to the NitroHSM Key, as the code:

CardTerminal c = r.cardTerminalForName( “Nitrokey Nitrokey HSM 0” );

correctly returns the CardTerminal.

Thanks in advance for your help.