ebics-java / ebics-java-client

Java open source EBICS client - Support for French, German and Swiss banks
GNU Lesser General Public License v2.1
36 stars 35 forks source link

Importing existing public and private keys #2

Closed andre1219 closed 4 years ago

andre1219 commented 4 years ago

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?