Skip to main content

PEMParser return null and the boxPrivateKey is base64

  • April 9, 2024
  • 1 reply
  • 111 views

Security.addProvider(new BouncyCastleProvider());

PEMParser pemParser = new PEMParser(
  new StringReader(config.boxAppSettings.appAuth.privateKey)
);
Object keyPair = pemParser.readObject();
pemParser.close();

the keyPair return null?

1 reply

rbarbosa Box
Forum|alt.badge.img
  • Developer Advocate
  • April 10, 2024

Hi @moaldini , welcome to the forum!

If you got the private key from Box while setting up the JWT application, please note the private key is encrypted.

You can extract it using something like:

openssl rsa -in your_encrypted_private-key-file.pem -out decrypted-private-key-file.pem  -passin pass:your-pass-phrase

Most likely Bouncy Caste will also have methods to decrypt a private key.

Let us know if this helps