Skip to main content
Participating Frequently
Jan 22, 2024 2:57 PM UTC

Box API and AWS Kendra integration, PKCS private key format error.

I am using trial version of Enterprise Box and I have created Box Custom application (authorized by Box admin). Then I generated a private key PK for that Box application and I use this PK to connect to Box App from AWS Kendra. I use Kendra Developer Edition in this test.

This method used to work, however today I received the below connection error after providing new PK to Kendra. PK is passed to Kendra using Secrets Manager.

Error connecting to customer repository: Error parsing PKCS private key for Box Developer Edition.

I made sure the PK is copied properly to Kendra. I also tested connectivity using the same PK and Box SDK and I can connect successfully to Box App programmatically using Python, however the connection from AWS Console fails.

What can cause this error?

This is private key format generated from BOX Application. It contains “\n” character as text. I normally copy “privateKey” into secret in Secrets Manager Kendra uses and this used to work.

{
  "boxAppSettings": {
    "clientID": "2rlrtiu5t22mkxp3nwsf3dvpr10eixxu",
    "clientSecret": "UtrXS40pQ5xZrAa3FpUGSlnBBudO12Ws",
    "appAuth": {
      "publicKeyID": "vs8qadc3",
      "privateKey": "-----BEGIN ENCRYPTED PRIVATE KEY-----\nMIIFHDBOBgkqhkiG9w0BBQ0wQTApBgkqhkiG9w0BBQwwHAQIhVU1bLSvgl8CAggA\nMAwGCCqGSIb3DQIJBQAwFAYIKoZIhvcNAwcECJ0m3yAKcUwpBIIEyKXKY3BVdPEU\noV0Ggy7XwLAyOTVbeiH+9amokZipHJdsvDT8DMDIawZsi/SATmWPqniJZjJgv0NC\n4Ao6xX5xRdqWbEUIw/ALfGje0m2XVu1ciZwApwDCIAR+ftd8DGEERJlGgV+7nqnm\nCTjuvXfj/rVBopLpL1XJ+I9esAvckLGc3t5UkR9NY0vHzDqsJ72Gsq1wj+uR2DTl\n8P2rwFDhhdhbQyWKr01FHmvNIsP1rHvLhG6/wcpiG+8CGcq/OX3vyZuUSO0rFPIL\n48iZvfh8bLwVllKuDSpdnj7xHlRF9KRmsgnSQ7wD1Rf5sshoMdltQMEp2nh7qstx\nG3tCSaR2tP8mf8MT5fUzTBCpjZH7rGt6YANgxIUZgwCAMMPfRxHc2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\nFChliTTkhr2L8Rwmfyq4PUQeov6QCfSMROaZ43woZJO75gJiFh1VcJyUV0+DWSLg\nzudVAvL8HvCH04djyWzVIdS0zC00bg086rWajDO2hqWJ2aNVNnbJX6uEM67wmCJW\nPXID7YcZsgCzzK0vg/WvFSNXqot0tsWhErH4tTezi6SD069UiV6Uuvb210ec6RWc\n6azMGCHf0q2skks79+e6UQ==\n-----END ENCRYPTED PRIVATE KEY-----\n",
      "passphrase": "213271f6a649e78d9366ebaeae2e6c47"
    }
  },
  "enterpriseID": "7630518952"
}

I tested various formats of this private key with “\n”, without “\n”, “\n” replaced with space, copy as “plain text” in Secrets Manager. All attempts ended with the same error - can not parse PKCS.

0

Post actions

16 replies

danieldAuthor
Participating Frequently
Jan 25, 2024 4:06 PM UTC

Hi @rbarbosa,

Right. My current environment is fully new, except for IAM role for Kendra, which I reused …and the key has changed in the meantime.

I formatted the private key in exactly the same way as you have done, and I also added the formatted key to key/value field, but the old KMS key (before rotation) has been used for the test and the test failed.

Now I am going to test the combination: newest KMS key with “\n” → new line conversion (for private key) in the key/value field (Secrets Manager). Hopefully this will work.

Translate
danieldAuthor
Participating Frequently
Jan 26, 2024 12:33 PM UTC

Hi @rbarbosa,

Even though I have used the current KMS key and replaced “\n” with new line in PK, the test failed with the same error. I can only think that this is due to how Windows encodes new line character which is CRLF (and I use Windows). In your case, new line character will be probably be LF instead of CRLF (since you use Mac), so I will have to do yet another test.

Translate
danieldAuthor
Participating Frequently
Feb 8, 2024 10:51 AM UTC

Hi @rbarbosa,

Unfortunately, I lost access to my test environment and had no chance to do the last test, my BOX account two weeks trial has expired. I am left only with AWS environment. I have to put on hold this testing.

I don’t know if I can ask, but would it be possible to connect to your Box App from my AWS account ?

Translate
rbarbosa Box
Developer Advocate
Feb 8, 2024 5:30 PM UTC

Hi @danield ,

It is not possible to connect using my account, sorry.

But wouldn’t a free account work for your test?

Cheers

Translate
danieldAuthor
Participating Frequently
Mar 25, 2024 5:32 AM UTC

Hi @rbarbosa,

My apology for late reply. About this issue I received communication from AWS that it was Kendra’s bug preventing me to connect to BOX App. The bug is now fixed by AWS and I can connect to BOX App. Thank you for your support, it helped me to narrow down the issue with Kendra.

However, I have yet another problem. I would like to scan documents in Box using App User created in Box App. This App User has permission to access limited number of Enterprise files. When Kendra performs scan with App Only user scope, in Kendra’s log I can see that limited set of files is detected (this is correct), but the files are not added to Kendra’s index. Do you know maybe if indexing via App User is supported by Box/Kendra?

(Should I open new topic for this issue?)
Best regards,
Daniel

Translate
rbarbosa Box
Developer Advocate
Mar 28, 2024 9:19 PM UTC

Hi @danield

That is strange, and I’m not sure what we can do on the box side, since it should add those files to the index.

Just to eliminate all possibilities, if you create a simple download script, or using Postman, can you download those files when using Kendra’s security context (the APP user?)

Translate