title: Storing certificates in pkcs11 keystore
body: <p>I am generating an RSA keypair in pkcs11 keystore, it was storing into smartcard and i am generating pkcs10 request. when i download the equivalent certificate how can i store it into smartcard(without privatekey since the key is already stored into smartcard) since i dont have access to the private key in the pkcs11 keystore.</p>
  
  <pre><code>    String wdtokenpath = "path to dll file";
      String pkcs11ConfigSettings = "name = SmartCard\n" + "library =" + wdtokenpath;
      byte[] pkcs11ConfigBytes = pkcs11ConfigSettings.getBytes();
      ByteArrayInputStream confStream = new ByteArrayInputStream(pkcs11ConfigBytes);
      Provider pkcs11Provider = null;
  
      Class sunPkcs11Class = Class.forName("sun.security.pkcs11.SunPKCS11");
      Constructor pkcs11Constr = sunPkcs11Class.getConstructor(
              java.io.InputStream.class);
      pkcs11Provider = (Provider) pkcs11Constr.newInstance(confStream);
      CallbackHandler call = new TextCallbackHandler();
      Subject token = new Subject();
      AuthProvider aprov = (AuthProvider) pkcs11Provider;
      aprov.login(token, call);
  
      System.out.println("Login successfully");
      KeyPairGenerator keyGen1 = KeyPairGenerator.getInstance("RSA", aprov);
      keyGen1.initialize(2048);
      KeyPair pair1 = keyGen1.generateKeyPair();
      PublicKey publicKey1 = pair1.getPublic();
  
      String sigAlg = "SHA1withRSA";
      PKCS10 pkcs10 = new PKCS10(publicKey1);
      Signature signature = Signature.getInstance("SHA1withRSA", pkcs11Provider);
      signature.initSign(pair1.getPrivate());
  </code></pre>