Error when using box generated API Keys in Java SDK
Hi,
we are trying to use the Box API keys inside the Java SDK, I'm getting the following error
i was able to use the developer token, when we generate public keys from the developer console and downloaded the configuration and using the JSON file we are getting the following error
any help is much appricated
Below is the stack trace:
com.box.sdk.BoxAPIException: Error parsing PKCS private key for Box Developer Edition.
at com.box.sdk.BoxDeveloperEditionAPIConnection.decryptPrivateKey(BoxDeveloperEditionAPIConnection.java:470)
at com.box.sdk.BoxDeveloperEditionAPIConnection.constructJWTAssertion(BoxDeveloperEditionAPIConnection.java:405)
at com.box.sdk.BoxDeveloperEditionAPIConnection.authenticate(BoxDeveloperEditionAPIConnection.java:315)
at com.box.sdk.BoxDeveloperEditionAPIConnection.tryRestoreUsingAccessTokenCache(BoxDeveloperEditionAPIConnection.java:383)
at com.box.sdk.BoxDeveloperEditionAPIConnection.getAppEnterpriseConnection(BoxDeveloperEditionAPIConnection.java:194)
at com.box.sdk.BoxDeveloperEditionAPIConnection.getAppEnterpriseConnection(BoxDeveloperEditionAPIConnection.java:221)
at com.box.sdk.BoxMain.Connect(BoxMain.java:92)
at com.box.sdk.BoxMain.main(BoxMain.java:40)
Caused by: org.bouncycastle.pkcs.PKCSException: unable to read encrypted data: 1.2.840.113549.1.5.13 not available: Illegal key size
at org.bouncycastle.pkcs.PKCS8EncryptedPrivateKeyInfo.decryptPrivateKeyInfo(Unknown Source)
at com.box.sdk.BoxDeveloperEditionAPIConnection.decryptPrivateKey(BoxDeveloperEditionAPIConnection.java:459)
... 7 more
Caused by: org.bouncycastle.operator.OperatorCreationException: 1.2.840.113549.1.5.13 not available: Illegal key size
at org.bouncycastle.openssl.jcajce.JceOpenSSLPKCS8DecryptorProviderBuilder$1.get(Unknown Source)
... 9 more
Caused by: java.security.InvalidKeyException: Illegal key size
at javax.crypto.Cipher.checkCryptoPerm(Cipher.java:1039)
at javax.crypto.Cipher.checkCryptoPerm(Cipher.java:1060)
at javax.crypto.Cipher.init(Cipher.java:1536)
at javax.crypto.Cipher.init(Cipher.java:1470)
... 10 more
-
Hi ,
This can be due to a few things - if the below suggestions don't provide a solution if you could provide your Java code we can dig further.
When you download the auto-generated config file, are you extracting the key from inside that file and trying to use that as the key? If so that would probably be the issue.
When using the downloaded config file, please try to generate the token like so: https://box.dev/en/guides/authentication/jwt/with-sdk/#1-read-json-configuration
Thanks,
Jon
Please sign in to leave a comment.
Comments
1 comment