I am trying to create an RSA key pair and store it in the HSM key store. The code I have now looks like this:
String configName = "C:\\eTokenConfig.cfg"; Provider p = new sun.security.pkcs11.SunPKCS11(configName); Security.addProvider(p); // Read the keystore form the smart card char[] pin = { 'p', '4', 's', 's', 'w', '0', 'r', 'd' }; KeyStore keyStore = KeyStore.getInstance("PKCS11",p); keyStore.load(null, pin); //generate keys KeyPairGenerator kpg = KeyPairGenerator.getInstance("RSA",p); kpg.initialize(512); KeyPair pair = kpg.generateKeyPair(); PrivateKey privateKey = pair.getPrivate(); PublicKey publicKey = pair.getPublic(); // Save Keys How ???
I tried using the keyStore.setEntry method, but the problem is that this requires a certificate chain, and I don't know how to get this certificate
value
source share