0

我加载私有(private.pem)我的代码是:

    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();
    }

错误是: 引起:

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

谢谢。

4

1 回答 1

3

您是否尝试添加:

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

编辑:您可能想去Why java.security.NoSuchProviderException No such provider: BC? 这可能会导致同样的问题。

于 2012-08-10T08:21:57.963 回答