Error parsing PKCS private key for Box Developer Edition - Gradle
Hi everyone,
I'm trying to Authenticate with my application using JWT with SDK, I have followed the tutorial, generated a public/private key pair using the Box platform, and stored the Json config file in my project.
Following the tutorial I first tried with the code example AccessAsAppUser.java and didn't found any issue.
But when I tried to replicate that example on my project, I'm getting the following exception:
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:515) at com.box.sdk.BoxDeveloperEditionAPIConnection.constructJWTAssertion(BoxDeveloperEditionAPIConnection.java:450) at com.box.sdk.BoxDeveloperEditionAPIConnection.constructJWTAssertion(BoxDeveloperEditionAPIConnection.java:431) at com.box.sdk.BoxDeveloperEditionAPIConnection.authenticate(BoxDeveloperEditionAPIConnection.java:320) at com.box.sdk.BoxDeveloperEditionAPIConnection.tryRestoreUsingAccessTokenCache(BoxDeveloperEditionAPIConnection.java:419) at com.box.sdk.BoxDeveloperEditionAPIConnection.getAppEnterpriseConnection(BoxDeveloperEditionAPIConnection.java:199) at com.box.sdk.BoxDeveloperEditionAPIConnection.getAppEnterpriseConnection(BoxDeveloperEditionAPIConnection.java:226) at com.cisco.s3.api.box.BoxBaseClient.(BoxBaseClient.java:39) at com.cisco.s3.api.box.BoxBaseClient.main(BoxBaseClient.java:56) Caused by: org.bouncycastle.pkcs.PKCSException: unable to read encrypted data: 1.2.***number removed for privacy***.1.5.13 not available: JCE cannot authenticate the provider BC at org.bouncycastle.pkcs.PKCS8EncryptedPrivateKeyInfo.decryptPrivateKeyInfo(Unknown Source) at com.box.sdk.BoxDeveloperEditionAPIConnection.decryptPrivateKey(BoxDeveloperEditionAPIConnection.java:504) ... 8 more Caused by: org.bouncycastle.operator.OperatorCreationException: 1.2.***number removed for privacy***.1.5.13 not available: JCE cannot authenticate the provider BC at org.bouncycastle.openssl.jcajce.JceOpenSSLPKCS8DecryptorProviderBuilder$1.get(Unknown Source) ... 10 more Caused by: java.security.NoSuchProviderException: JCE cannot authenticate the provider BC at javax.crypto.JceSecurity.getInstance(JceSecurity.java:105) at javax.crypto.SecretKeyFactory.getInstance(SecretKeyFactory.java:204) at org.bouncycastle.jcajce.util.NamedJcaJceHelper.createSecretKeyFactory(Unknown Source) at org.bouncycastle.openssl.jcajce.PEMUtilities.generateSecretKeyForPKCS5Scheme2(Unknown Source) ... 11 more Caused by: java.util.jar.JarException: file:/[FILE].jar has unsigned entries - com/box/sdk/example/Main.class at javax.crypto.JarVerifier.verifySingleJar(JarVerifier.java:502) at javax.crypto.JarVerifier.verifyJars(JarVerifier.java:363) at javax.crypto.JarVerifier.verify(JarVerifier.java:289) at javax.crypto.JceSecurity.verifyProviderJar(JceSecurity.java:164) at javax.crypto.JceSecurity.getVerificationResult(JceSecurity.java:190) at javax.crypto.JceSecurity.getInstance(JceSecurity.java:102) ... 14 more
Is this a bug? I have installed the JCE in the java 1.8 folder, but I'm still getting that exception.
More information:
I'm using the Java SDK and adding it to my project with the Maven dependency:
compile 'com.box:box-java-sdk:2.23.2'
java version "1.8.0_171"
Java(TM) SE Runtime Environment (build 1.8.0_171-b11)
Java HotSpot(TM) 64-Bit Server VM (build 25.171-b11, mixed mode)
-
I have followed the article: JCE cannot authenticate the provider BC and I don't see the exception now.
But if someone found a workaround instead of modifying java.security and copying jar to \jre\lib\ext; would be really appreciated 🙂
-
: It looks like your error is similar to the one shown on the Java SDK GitHub here (https://github.com/box/box-java-sdk/issues/473).
Please sign in to leave a comment.
Comments
2 comments