When following the instructions for instantiating/creating a new API connection to Box with the Box for Salesforce SDK, the following error message can be returned:
System.SecurityException: Invalid Crypto Key
Environment
Box for Salesforce SDK
Steps To Resolve
Verify that the private key has been properly formatted and decrypted.
- Copy/pasted the encrypted private key from the downloaded .json into a new .pem document
- Leave in "-----BEGIN ENCRYPTED PRIVATE KEY-----" and "-----END ENCRYPTED PRIVATE KEY-----" at the top and bottom, respectively, each on their own lines
- For the encoded certificate, make a new line every 65 characters
- On a computer with openssl installed open a UNIX/macOS terminal window or a Windows PowerShell window and run the following command
openssl pkcs8 -topk8 -nocrypt -in your_private_key.pem -outform PEM - Terminal then prompts for the private key passphrase (found the .json file)
- A decoded private key is returned.
- Copy all content between the begin/end terms into a single line for "YOUR_PRIVATE_KEY".
Root Cause
Improperly formatted or decrypted private key.
platform_swarm_kb