encryptionKey

encryptionKey

This setting was added in Profound.js version 7.0.0.

Description

Specifies the encryption key used for built-in encryption features. The key must be specified as a Node.js Buffer object of exactly 32 bytes. Anything else – a string, or a Buffer of a different length – causes a configuration error at startup.

An encryption key is required by connectorCredentials, basicAuthCredentials, the credentialsFile property of databaseConnections, and encrypted sslOptions. Instances that use any of those will not start without it.

Example 1: Load the Key From a File

To load the key from a file created by gen_key.js, add these lines to the top of your configuration file if they are not already present:

const fs = require("fs"); const path = require("path");

And then populate the setting like this. __dirname resolves to the installation directory, so the key file sits alongside config.js:

"encryptionKey": fs.readFileSync(path.join(__dirname, "ekey"))

Example 2: Load the Key From Another Source

Because config.js is ordinary JavaScript, the key can be loaded from anywhere. This reads it from a Base64-encoded environment variable named ENCRYPTION_KEY, which keeps the key out of the file system entirely – useful in a container where the variable comes from a Secret:

"encryptionKey": Buffer.from(process.env.ENCRYPTION_KEY, "base64")

For information on how to modify this setting, see Configuration File.