0

I load private (private.pem) my code is:

    FileReader fileReader = new FileReader(new File(private.pem));
    PEMReader r = new PEMReader(fileReader, new DefaultPasswordFinder("mypass".toCharArray()));
    try {
        KeyPair kp = (KeyPair) r.readObject();
    } catch (IOException ex) {
        throw new IOException("The private key could not be decrypted", ex);
    } finally {
        r.close();
        fileReader.close();
    }

error is : Caused by:

java.io.IOException: problem creating RSA private key: java.security.NoSuchProviderException: No such provider: BC at org.bouncycastle.openssl.PEMReader.readObject(Unknown Source)

thanks.

slayton
  • 20,123
  • 10
  • 60
  • 89
cldo
  • 1,735
  • 6
  • 21
  • 26

1 Answers1

3

Did you try adding :

Security.addProvider(new org.bouncycastle.jce.provider.BouncyCastleProvider());

Edit : You may want to go to Why java.security.NoSuchProviderException No such provider: BC? which may lead to the same problem.

Community
  • 1
  • 1
Michael Laffargue
  • 10,116
  • 6
  • 42
  • 76