Reading encryption keys using an external command
NSO supports reading encryption keys using an external
command instead of storing them in ncs.conf
to allow for use with external key management systems. To use
this feature set
/ncs-config/encrypted-strings/external-keys/command
to an executable command that will output the keys following the
rules described in the following sections. The command will be
executed on startup and when NSO reloads the
configuration.
If the external command fails during startup, the startup will
abort. If the command fails during a reload the error will be
logged and the previously loaded keys will be kept in the
system.
The process of providing encryption keys to NSO can be
described by the following three steps:
-
Read configuration from environment.
-
Read encryption keys.
-
Write encryption keys or error on standard output.
The value of
/ncs-config/encrypted-strings/external-keys/command-argument
is available in the command as the environment variable
NCS_EXTERNAL_KEYS_ARGUMENT
. The value of this
configuration is only used by the configured command.
The external command should return the encryption keys on
standard output using the names as shown in the table below. The
encryption key values are in hexadecimal format, just as in
ncs.conf
. See the example below for
details.
Table 8.
Mapping from name to path in configuration.
Name |
Configuration path |
DES3CBC_KEY1 |
/ncs-config/encrypted-strings/DES3CBC/key1 |
DES3CBC_KEY2 |
/ncs-config/encrypted-strings/DES3CBC/key2 |
DES3CBC_KEY3 |
/ncs-config/encrypted-strings/DES3CBC/key3 |
DES3CBC_IV |
/ncs-config/encrypted-strings/DES3CBC/initVector |
AESCFB128_KEY |
/ncs-config/encrypted-strings/AESCFB128/key |
AESCFB128_IV |
/ncs-config/encrypted-strings/AESCFB128/initVector |
AES256CFB128_KEY |
/ncs-config/encrypted-strings/AES256CFB128/key |
To signal an error, including ERROR=message is preferred. A
non-zero exit code or unsupported line content will also
trigger an error. Any form of error will be logged to the
development log and no encryption keys will be available in
the system.
Example output providing all supported encryption key
configuration settings:
Example error output:
Below follows a complete example of an application written
in Python providing encryption keys from a plain text
file. The application is included in the example
crypto/external_keys
: