How to generate certificate with pkcs11 in JAVA -
i generated rsa keypair pkcs11 , don't know how generate csr , certificate. working code, keypair generated.
// set sun pkcs 11 provider string configname = "hsmconfig.cfg"; provider p = new sunpkcs11(configname); if (-1 == security.addprovider(p)) { throw new runtimeexception("could not add security provider"); } // load key store char[] pin = "ocsocsp3".tochararray(); keystore ks = keystore.getinstance("pkcs11", p); ks.load(null, pin); // generate key securerandom sr = new securerandom(); keypairgenerator keygen = keypairgenerator.getinstance("rsa", p); keygen.initialize(1024, sr); keypair keypair = keygen.generatekeypair(); privatekey pk = keypair.getprivate(); publickey pub = keypair.getpublic();
Comments
Post a Comment