The Salesforce crypto class documentation specifies that a private key should be stored as a protected custom setting.

"A PKCS8 formatted private key in base64 decoded form is required. This private key should not be hardcoded in the Apex script but should be stored in a protected custom setting or a encrypted fields in a custom table"


How do I do this because it seems that custom setting field values are limited to 255 characters?


1 Answer 1


The only decent option is to split the private key into separate parts (probably around 10) and save those into the fields. Then in your code, concatenate the parts into the complete key.

I personally prefer a custom object field because it can be encrypted. Custom settings are accessible by all users with view setup/config rights.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .