Skip to main content

Decrypting private key in ColdFusion

  • February 26, 2024
  • 8 replies
  • 155 views

patientnut

I’m following these instructions and I am struggling to decrypt the private key in ColdFusion/Lucee.

Here’s how it’s done in PHP:

$private_key = $config->boxAppSettings->appAuth->privateKey;
$passphrase = $config->boxAppSettings->appAuth->passphrase;
$key = openssl_pkey_get_private($private_key, $passphrase);

Has anyone managed to get it working?

8 replies

patientnut
  • Author
  • New Participant
  • 2 replies
  • February 26, 2024

I’ve skipped this step for the time-being and decrypted the private key in Terminal instead, but I’d be interested to know if anyone has got this working in ColdFusion/Lucee.


rbarbosa Box
  • Developer Advocate
  • 553 replies
  • February 26, 2024

Hi @patientnut , welcome to the forum.

I’m not familiar with Lucee, so I don’t know what it provides in terms of private key decryption. I’ve tried to do the same using javascript and struggled to find a library that would offer that out of the box.

You found the workaround though.

Let’s see if other members working with ColdFusion/Lucee respond.

Cheers


  • 4 replies
  • March 11, 2024

Hi
I have been trying to decrypt the Box Private Key in Windows Terminal but did not succeed.
Could you please provide a step-by-step instruction for dummies that includes everything I need to do ?
I am not a developer so please leave nothing out 😉
I would really appreciate you help as I have been struggling with this for quite some time now.
Cheers


patientnut
  • Author
  • New Participant
  • 2 replies
  • March 11, 2024

This is how it’s done on Mac, so you’ll need to find the Windows equivalent.

  1. Copy the privateKey from config.json and paste it into a new encrypted_private.key file.
  2. Replace all occurrences of \n with new lines.
  3. In Terminal, run openssl rsa -in encrypted_private.key -out decrypted_private.key.

This decrypts the private key and stores it in decrypted_private.key.


  • 4 replies
  • March 11, 2024

Thanks for getting back to me !!

I have created the following file : BOX_encrypted_private_key.key
The file looks like this:

I then open Terminal and tried different ways as picture below shows.
But I keep getting errors as shown in picture.

I have also tried to put the location in command in Terminal, like this :
openssl rsa -in C:\Users\xxx.yyy\Downloads\BOX_encrypted_private_key.key -out C:\Users\xxx.yyy\Downloads\BOX_de_encrypted_private_key.key

But I still get the same erros in Terminal.

Can you tell me what is wrong ?


  • 4 replies
  • March 11, 2024

Forgot to mention that Box documentation on this URL : https://developer.box.com/guides/authentication/jwt/without-sdk/#2-decrypt-private-key

Explains that I need a passcode to unlock the encrypted file. I do have the passcode for this but don´t know where to put it in Terminal ?


rbarbosa Box
  • Developer Advocate
  • 553 replies
  • March 11, 2024

Hi @laa ,

Looks like openssl is not installed or not in the path of your windows…


  • 4 replies
  • March 14, 2024

Thanks for your reply.
I had issues with openSSL and now changed to use Client and Secret for getting my Access Token.
Application now works as expected 😉


Reply


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings