Server key encryption methods
This topic describes the available methods for encrypting the server keys which include the data key, the Conjur UI key, and SSL keys.
Encrypt server keys using a master key file
During the initial configuration of the Leader Conjur Server (Leader), evoke configure master generates server keys and places them in /opt/conjur/etc and /opt/conjur/etc/ssl.
For example:
- Database encryption key: possum.key
- UI encryption key: ui.key
- SSL private keys: conjur.key, ca.key
Use the evoke keys commands to encrypt the keys and unlock the encrypted keys to the Linux keyring and memory based file system.
|
-
Configure the Leader:
Log in to the Leader and run the following:
# Configure the Conjur Leader evoke configure master -h conjur-master.yourcorp -p password mycorp # Lock the server keys evoke keys lock # Generate a random master key. Keep this file secure openssl rand 32 > /secrets/master.key # Encrypt the server keys with the 32-byte master key evoke keys encrypt /secrets/master.key # Unlock the server keys and restart the Conjur services evoke keys unlock /secrets/master.key # In the log, you will see "Searching keyring for key" and "Read key for" for all Conjur services
Once complete, the Leader runs and uses the secured keys.
The /opt/conjur/etc directory now contains only the encrypted server keys.
Note the enc suffix:
- possum.key.enc
-
ui.key.enc
- conjur.key.enc, ca.key.enc (in /opt/conjur/etc/ssl)
Now that the keys are encrypted, they must be unlocked before starting any services. Unlocking is required on every server/VM/container boot or restart. The key must be provided by the administrator.
-
Configure a high availability (HA) cluster:
The basic process for setting up a Standby/Follower in an HA cluster involves:
- Creating the server keys on the Leader
- Encrypting the server keys
- Generating a Standby/Follower seed file on the Leader
- Transferring the seed file to the Standby/Follower
- Unpacking the seed file on the Standby/Follower and configuring the Standby/Follower
Because the seed file contains only encrypted key material, the seed file is secure. Only someone with the master key is able to decrypt the key material in the seed file.
An HA cluster includes a Leader, Standbys, and Followers. The following procedure describes setting up a Follower but the process is the same for the other types of cluster nodes - simply replace the word follower with standby.
-
Generate a Follower seed on the Leader
Run the following commands on the Leader. The example assumes the master key file , master.key, created when configuring the Leader) is located in /secrets/.
# Generate the certificate for the Follower evoke keys decrypt-all /secrets/master.key evoke ca issue conjur-east.yourcorp # Encrypt the keys evoke keys encrypt /secrets/master.key # Create a secure seed file on the Leader evoke seed follower conjur-east.yourcorp conjur-master.yourcorp > /seed/conjur-east.yourcorp.tar
-
Copy files to the Follower
Transfer conjur-east.yourcorp.tar to the Follower. Transfer /secrets/master.key to the Follower.
-
Load the seed file on the Follower:
# Unpack the Follower seed file evoke unpack seed /seed/conjur-east.yourcorp.tar # Configure the Follower evoke keys exec -m /secrets/master.key -- evoke configure follower
For an HA configuration, the
evoke seed follower
command ensures that the encrypted keys in /opt/conjur/etc are included in the seed file created on the Leader.It is not necessary to use the
evoke keys encrypt
command on the Follower because the keys are already encrypted in the seed file. However, prior to starting the service on the Follower you do need to useevoke keys unlock
, orevoke keys exec
, with the same master key used to encrypt the server keys on the Leader.
Backup and restore with a master key file
After encrypting the server keys, you must provide the master key file to use evoke restore
.
This example assumes you have put the master key file, master.key, created when configuring the Leader, into /secrets/:
|
|
Encrypt the master key using AWS KMS
You can encrypt the master key using the Amazon Key Management Service (AWS KMS) master key facility.
-
Create a KMS CMK
Create a KMS customer master key (CMK) using your preferred interface (for example: CLI, web console etc).
This CMK must meet the following criteria:
-
The key must be symmetric.
-
The key policy must allow the role that deploys the Conjur node in EC2 to decrypt the KMS key, as shown in the following example:
{ "Version": "2012-10-17", "Id": "conjur-key-policy-<region>", "Statement": [ { "Sid": "Allow use of the key by Conjur", "Effect": "Allow", "Principal": { "AWS": "<arn of role deploying Conjur>" }, "Action": "kms:Decrypt", "Resource": "*" }, { "Sid": "Allow access for Key Administrators", "Effect": "Allow", "Principal": { "AWS": "<arn of key administrator>" }, "Action": [ "kms:*", ], "Resource": "*" } ] }
Be sure to follow your organization's best practices and security policies when defining your AWS IAM policy for the key.
AWS CLI example
The following example uses the AWS CLI to create the CMK, however, the web console can also be used. For more information, see the AWS KMS documentation.
aws kms create-key --policy <value> --description "Conjur regional master key encryption key" --key-usage "ENCRYPT_DECRYPT"
-
-
Generate an encrypted Conjur master key
Encrypted Conjur master keys are stored as ciphertextBlobs.
-
Set the key_spec to 'AES_256'.
-
Run
generate_data_key_without_plaintext
against the KMS CMK created in Server key encryption methods.
AWS CLI example
The following example uses the AWS CLI to generate an encrypted master key, however, the web console can also be used. For more information, see the AWS KMS documentation.
aws kms generate-data-key-without-plaintext --key-id <arn of KMS key> --key-spec "AES_256" --encryption-context KeyType="Conjur master key"
-
-
Import ciphertextBlob into the Conjur node
This procedure should be performed by a Conjur administrator.
Run the
evoke keys kms set
command to import the ciphertextBlob into the Conjur node.The KMS key and the role associated with the Conjur node must be in the same AWS region.
-
Encrypt the keys
This procedure should be performed by a Conjur administrator.
Run the
evoke keys encrypt
command.evoke keys encrypt
locates its region either from the environment variableAWS_REGION
or from the identity documents.The credentials for an AWS role can be retrieved from the role that deployed the Conjur node. For additional methods for retrieving these credentials, see the AWS documentation.
For more information, see Evoke command reference.
Encrypt the master key using an HSM (4.9.2.0+)
Conjur supports the use of a PKCS#11-compliant hardware security
module (HSM) to securely manage the master key (master.key). The
evoke pkcs11
subcommand uses the HSM to:
- generate a key encryption key
- wrap (i.e. encrypt) the master key (master.key) with the key encryption key
- encrypt the service keys with the master key
- store the wrapped master key
The key encryption key never leaves the HSM.
Once the master key has been wrapped, the evoke keys
subcommands use the HSM to unwrap it when performing their
respective functions.
Terminology
These are some of the terms specific to using an HSM.
Term |
Description |
---|---|
|
According to Wikipedia, an HSM is "a physical computing device that safeguards and manages digital keys for strong authentication and provides cryptoprocessing". |
|
A key that is generated and maintained by the HSM, and is used to encrypt other keys. |
|
Often shortened to "token", this is a storage device that plugs in to the HSM and stores key encryption keys. |
|
HSM operations to encrypt and decrypt a key, respectively. |
Overview of operation with an HSM
At the highest level, using the PKCS#11 support involves:
-
Obtaining a Linux x86_64 shared library for your HSM, and copying it to the Conjur Server.
-
Configuring Conjur's PKCS#11 support to use the shared library
-
Having the HSM generate a new key encryption key
-
Wrapping the master key (optionally generating a new one) with the key encryption key
-
Encrypting the server keys with the master key
Configure the appliance
To use an HSM with Conjur, you must first obtain the Linux x86_64 shared library appropriate for your HSM. Copy it to the Conjur Server.
Once you have the shared library, you must create the file /opt/conjur/etc/pkcs11.yml and add configuration information to it.
Next, validate that the file has the appropriate permissions:
|
This command validates that only the owner has read and write permissions on the file.
The following settings can appear in the file:
Element |
Description |
---|---|
library |
Full path to the shared object containing the PKCS#11 module to use. Required |
wrapping_key |
Module ID of the key used to wrap the master key. If you choose to generate a key encryption key, it will be stored with this ID. Required |
parameters |
A hash or a string with additional parameters to be passed to the module. Optional |
slot |
Index of the HSM slot containing the token to use (zero-based). If omitted, the first slot supporting key storage is automatically used. Optional |
pin |
PIN for logging into the module. If omitted, an empty password is assumed. Optional |
As an example, this pkcs11.yml file configures the Conjur Server to use the NSS Softoken Cryptographic Module. Softoken, available as part of the libnss3 package, is a PKCS#11 module that stores key encryption keys in the file system:
|
Generate a key encryption key
Once HSM support is configured, use evoke pkcs11 generate
to have
the HSM create a key encryption key and store it on the token.
For help on this function, run:
|
Wrap the master key
After creating the key encryption key, use evoke pkcs11 wrap
to
wrap the master key.
If you have previously encrypted your keys, you will need to
provide that master key. Otherwise, evoke pkcs11 wrap
will
generate a new random 32-byte master key.
For help on this function, run:
|
Use the wrapped master key
Once the master key has been wrapped, you no longer need to provide
a master key to evoke keys
subcommands.
For example, evoke keys lock
will unwrap the master key, and then use
it to encrypt the server keys. Similarly, evoke keys unlock
will
unwrap the master key, and then use it to decrypt the server keys and
put them in the kernel keyring.
For example:
|