Error parsing PKCS private key for Box Developer Edition and pad block corrupted


we are using java1.8 version and trying to get the Token using Java SDK , but we got the below exception.

above blog suggeste all the jar’s added.

Sample Code:
Path configPath = Paths.get(“config.json”);
try (BufferedReader reader = Files.newBufferedReader(configPath, Charset.forName(“UTF-8”))) {
BoxConfig boxConfig = BoxConfig.readFrom(reader);
BoxDeveloperEditionAPIConnection client = BoxDeveloperEditionAPIConnection.getAppEnterpriseConnection(boxConfig);

//Not able to get this token

}catch(Exception e){
System.out.println(“Error =”+e.getMessage());

This below exception, we are getting recently.

Exception in thread “main” Error parsing PKCS private key for Box Developer Edition.

Caused by: org.bouncycastle.pkcs.PKCSException: unable to read encrypted data: javax.crypto.BadPaddingException: pad block corrupted

Caused by: javax.crypto.BadPaddingException: pad block corrupted
at javax.crypto.CipherInputStream.getMoreData(
at Source)


Hi Srini, welcome to the forum.

Let me see if I can get the Java SDK folks to help with this question.


the way to resolve this issue is described in GitHub - box/box-java-sdk: The Box SDK for Java.

Hi Lukasz,

Thank you for the details , i will check it and implement it.


Hi Lsocha,

we had implemetned the changes suggested in this git link" GitHub - box/box-java-sdk: The Box SDK for Java. .

still we are gettting the same exception.
we came to know to fix this issue, we need to generate Custom decryption and configure it ?

FIPS 140-2 Compliance

How can we implement it Custom description for the box provided config.json file data?
How to know, what encoding format used to encript private key?
is there any example available to write Custom Decryption mentod for this Interface" IPrivateKeyDecryptor"
do we need to follow any Standards to implment Custom Description ?