Keys and secrets
Java Agent uses cryptographic keys for encryption, signing, and securing network connections, and passwords. The following sections discuss how to secure keys and secrets in your deployment.
Use strong keys
Small keys are easily compromised. Use at least the recommended key size.
In JVM, the default ephemeral Diffie-Hellman (DH) key size is 1024 bits. To support stronger ephemeral DH keys, and protect against weak keys, installations in Tomcat 8.5.37 and later versions use the Tomcat default DH key size of 2048-bit.
Increase the DH key size to protect against weak keys. For more information, refer to Customizing Size of Ephemeral Diffie-Hellman Keys
Create and rotate keys
Rotate keys regularly to:
-
Limit the amount of data protected by a single key.
-
Reduce dependence on specific keys, making it easier to migrate to stronger algorithms.
-
Prepare for when a key is compromised. The first time you try key rotation shouldn’t be during a real-time recovery.
-
Conform to internal business compliance requirements.
Rotate the agent profile password
During installation, the agent requests the path to a file containing the agent profile password. The agent then uses the following properties to encrypt and store the password:
-
am.encryption.pwd
in the AgentKey.properties file -
Encrypted Agent Password
in the AgentPassword.properties file
If the path is empty, the installation terminates with a configuration error.
The following steps describe how to rotate the agent profile password:
-
Change the profile password for your agent instance. For example, in the AM admin UI, change the password as follows:
-
Select Realms > realm name > Applications > Agents > Java.
-
Select your agent.
-
In the Global tab, enter a new password in the Password field.
-
-
Generate an encryption key for the agent profile password, using the agentadmin --getEncryptKey command:
$ agentadmin --getEncryptKey
-
In AgentKey.properties, set the value of
am.encryption.pwd
to the new value. -
Encrypt the agent profile password, using the agentadmin --encrypt command:
$ agentadmin --encrypt agent-instance password-file
The agent encrypts the password by using the value of
Encryption Key/Salt
from AgentKey.properties. -
In AgentKey.properties, set the value of
Encrypted Agent Password
to the new value. -
Restart the agent instance.
Create a cookie signing key
During installation, the agent requests the path to a file containing the cookie
signing key, and then uses the key to configure the property
org.forgerock.agents.cookie.signing.value
in
AgentKey.properties. If the
path is empty, cookie signing is disabled.
The key must be at least 64 characters long. If it is shorter, the agent rejects it and leaves cookies unsigned. For security, use a key of at least 80 characters.
-
Generate an 80-character key, using the agentadmin --key command:
-
Unix
-
Windows
$ agentadmin --key 80 ZRY...xXO
C:> agentadmin --key 80 ZRY...xXO
-
Rotate cookie signing keys
-
In AgentKey.properties, set the value of org.forgerock.agents.cookie.signing.value to the key value.
-
Restart the agent instance.