4

I'm trying to encrypt and sign a package with nCipher (Thales HSM), but when I try to do it, there is an exception saying that "There is no card in the slot". According to HSM admin there is a card, but it is not in the default slot, so one of the options is to change the default slot, but how can I do it? Or how can I workaround to the original exception?

Here is the code throwing the exception:

    KeyPairGenerator kpg = KeyPairGenerator.getInstance("RSA", "nCipherKM");
    kpg.initialize(2048);
    KeyPair kp = kpg.generateKeyPair();
    Signature signer = Signature.getInstance("SHA256withRSA","nCipherKM");
    signer.initSign(kp.getPrivate());
    signer.update(plainText);
    return new String(signer.sign(),UTF_8);
LuisEduardoSP
  • 401
  • 5
  • 11

1 Answers1

0

Adding -Dslot=2 to the Java command line can override which slot it uses.

zeroimpl
  • 2,746
  • 22
  • 19