Hello, is there a way to import already existing keys? actually I'm trying to generate a KeyPair with it in the createE002Certificate using :
byte[] byteKey = Base64.getDecoder().decode(pubkey.getBytes());
X509EncodedKeySpec spec = new X509EncodedKeySpec(byteKey);
KeyFactory fact = KeyFactory.getInstance("RSA");
PublicKey mypubkey = fact.generatePublic(spec);
byte[] keyByte = Base64.getDecoder().decode(privkey.getBytes());
PKCS8EncodedKeySpec keySpecPKCS8 = new PKCS8EncodedKeySpec(keyByte);
PrivateKey myprivkey = fact.generatePrivate(keySpecPKCS8);
but the result is java.security.InvalidKeyException: Public key presented not for certificate signature.
Hello, is there a way to import already existing keys? actually I'm trying to generate a KeyPair with it in the createE002Certificate using : byte[] byteKey = Base64.getDecoder().decode(pubkey.getBytes()); X509EncodedKeySpec spec = new X509EncodedKeySpec(byteKey); KeyFactory fact = KeyFactory.getInstance("RSA"); PublicKey mypubkey = fact.generatePublic(spec); byte[] keyByte = Base64.getDecoder().decode(privkey.getBytes()); PKCS8EncodedKeySpec keySpecPKCS8 = new PKCS8EncodedKeySpec(keyByte); PrivateKey myprivkey = fact.generatePrivate(keySpecPKCS8);
but the result is java.security.InvalidKeyException: Public key presented not for certificate signature.
Can someone give some help?