title: RSA keypair generation and storing to keystore
body: <p>I am tryng to generate RSA keypair and to store it on the HSM keystore. The code i have right now looks like this:</p>
  
  <pre><code>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 ???
  </code></pre>
  
  <p>I tried to use the keyStore.setEntry method but the problem is it requires a Certificate chain and I don't know how to get this certificate ??</p>