Skip to main content

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

  • February 12, 2024
  • 4 replies
  • 463 views

Hi,

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
System.out.println(client.getAccessToken());

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

This below exception, we are getting recently.

Exception in thread “main” com.box.sdk.BoxAPIException: Error parsing PKCS private key for Box Developer Edition.
at com.box.sdk.BoxDeveloperEditionAPIConnection.decryptPrivateKey(BoxDeveloperEditionAPIConnection.java:568)

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

Caused by: java.io.IOException: javax.crypto.BadPaddingException: pad block corrupted
at javax.crypto.CipherInputStream.getMoreData(CipherInputStream.java:128)
at javax.crypto.CipherInputStream.read(CipherInputStream.java:246)
at org.bouncycastle.util.io.Streams.pipeAll(Unknown Source)

Regards,
Srinivas.

4 replies

rbarbosa Box
  • Developer Advocate
  • 553 replies
  • February 12, 2024

Hi Srini, welcome to the forum.

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

Cheers


  • Participating Frequently
  • 15 replies
  • February 12, 2024

Hi,
the way to resolve this issue is described in README.md: GitHub - box/box-java-sdk: The Box SDK for Java.
Best,
Lukasz


  • Author
  • New Participant
  • 2 replies
  • February 13, 2024

Hi Lukasz,

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

Regards,
Srinivas.


  • Author
  • New Participant
  • 2 replies
  • February 19, 2024

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 ?


Reply


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings