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
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
- In a UNIX terminal (Macs), run the code
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".
Improperly formatted or decrypted private key.