Invalid cast exception
Hello, I am getting this exception after passing the boxconfig object to BoxJWTAuth.
BoxConfig boxConfig = new BoxConfig(CLIENT_ID, CLIENT_SECRET, ENTERPRISE_ID, PRIVATE_KEY, PRIVATE_KEY_PASSWORD, PUBLIC_KEY_ID);
BoxJWTAuth boxJWT = new BoxJWTAuth(boxConfig);
string adminToken = boxJWT.AdminToken();
Exception details:
Unable to cast object of type 'Org.BouncyCastle.Crypto.Parameters.RsaPrivateCrtKeyParameters' to type 'Org.BouncyCastle.Crypto.AsymmetricCipherKeyPair'.\"\r\n"
This Exception is thrown in this line-
BoxJWTAuth boxJWT = new BoxJWTAuth(boxConfig);
Do you think this might be happening because of the BOX SDK version? I have created a POC in my local machine in which I am generating the access token using JWT Auth by passing the private key in Boxconfig object in the below format and it is generating the access token. The Box SDK version that I am using in this POC project is 3.21.0, .net framework is 4.6
"-----BEGIN ENCRYPTED PRIVATE KEY-----\n**************************\n-----END ENCRYPTED PRIVATE KEY-----\n"
However, when I am integrating BOX in my existing MVC application to upload documents, it is throwing the casting error. The BOX SDK version used in my application is 2.15.6
PS- I am using the same private key in my MVC application.
Any help would be highly appreciated. Thanks
-
Hi ,
I haven't seen that direct issue before, but a few potential solutions:
- Can you try manually casting such as denoted here.
- Alternately, you can use the automatically download config JSON file from the application, rather than using a manually generated keypair.
- Jon
サインインしてコメントを残してください。
コメント
1件のコメント