79250278

Date: 2024-12-04 08:06:35
Score: 1
Natty:
Report link

Convert the multiline value to base64 and read the value in the file by converting it back to ascii.

  1. Convert the certificate to base64 using the below script and Keep it in .env variable.

    const fs= require('fs'); const key = fs.readFileSync(__dirname + '/certificate.crt', 'utf8'); const buff = Buffer.from(key).toString('base64'); console.log(buff);

  2. Read the variable from .env by converting it back. Buffer.from(process.env.HTTPS_KEY , 'base64').toString('ascii').

  3. New version of dotenv npm package supports multiline.

Reasons:
  • Long answer (-0.5):
  • No code block (0.5):
  • Low reputation (1):
Posted by: Dhanush K.S.