Skip to main content

Managing Encryption Keys

JAMS encrypts password and private key information when it is stored in the database. A database that uses the default encryption key is encrypted with a key that is built in to JAMS and is the same on every JAMS installation, so anyone who obtains the database, or a backup of it, can recover the stored passwords. Use a unique encryption key, and make sure that it is properly backed up and secured.

When a unique encryption key is set, JAMS uses the AES encryption algorithm to re-encrypt all password and private key information within the database. The key is then protected with the Windows Data Protection API (DPAPI) using the LocalMachine scope and stored in the database. The protected copy is tied to the machine that protected it, not to the account that runs the JAMS services, and it can only be unprotected on that machine. This is why the key must be exported to a file and kept safe: the file is the only copy that can be moved to another machine. It is also why, in a failover environment, each node keeps its own protected copy of the key and the key must be imported on the secondary.

Setting the Key During Installation​

When the JAMS installer creates a new JAMS Database, it displays the Database Encryption page. The page appears only when the JAMS Scheduler is selected for installation and the installer is creating the database. It does not appear when you reuse an existing database, which keeps the key it already has. See Installing JAMS.

The page offers three options:

  • Generate a new encryption key (recommended): The installer generates a unique 256 bit key, saves it to the file shown on the page, and applies it to the new database before any credentials are stored. The default file is <database>-<machine>-EncryptionKey.txt in the JAMS Scheduler installation directory, for example C:\Program Files\MVPSI\JAMS\Scheduler\JAMS-SERVER1-EncryptionKey.txt. The file must be on a local drive. This is the same as running GENERATE KEY and EXPORT KEY after the installation.
  • Restore an encryption key from a file: The installer reads a key that was exported from another JAMS installation and applies it to the new database. The file must be on a local drive.
  • Continue with the default encryption key: The database uses the built-in key. This is not recommended, and the installer asks you to confirm it. You can set a unique key later with GENERATE KEY.
warning

The key file is not encrypted. When the installation finishes, move it to a safe, secured location. It is the only backup of the key, and anyone who has it can decrypt the passwords in the database.

The result is recorded in DBUpdate.log in the JAMS Scheduler installation directory. If the installer cannot set the unique key, the database keeps the default key, and you should run GENERATE KEY and EXPORT KEY as described in Protecting a Standalone JAMS Server.

JAMSDBA Key Commands​

Use the following commands in the JAMSDBA utility to manage encryption keys. Each command takes the name of the tenant. On a standard installation, the tenant is named Default. Run HELP GENERATE KEY, HELP EXPORT KEY, or HELP IMPORT KEY at the JAMSDBA> prompt to display the syntax.

The commands work through the JAMS Server service on the local machine, so the JAMS Server service must be running.

GENERATE KEY <tenant> - Generates a new 256 bit encryption key, decrypts the passwords with the old key, and then encrypts them with the new key. The new encryption key is then protected with DPAPI. Example: GENERATE KEY Default

EXPORT KEY <file> <tenant> - Reads the encryption key, unprotects it, and writes it to a text file. Example: EXPORT KEY C:\Temp\YourFileName.txt Default

warning

It is critical that you protect the exported file since the key is not encrypted.

IMPORT KEY <file> <tenant> [/NOENCRYPT] - Similar to GENERATE KEY, but the new key is read from a text file instead of being generated. If you are recovering from a backup or configuring the secondary server in a failover environment, use the /NOENCRYPT qualifier to skip the decryption and re-encryption of the current data, because that data is already encrypted with the key in the file. Example: IMPORT KEY YourFileName.txt Default /NOENCRYPT

Protecting a Standalone JAMS Server​

If the key was generated by the installer, it is already protected, and you only need to move the saved key file to a safe location. To replace the key on an existing JAMS Server, follow the steps below:

  1. Log on to the server as a user with "Execute" access to JAMS configuration settings.
  2. Set your default directory to the JAMS Scheduler installation directory. The default is: C:\Program Files\MVPSI\JAMS\Scheduler
  3. Execute JAMSDBA.EXE to open a JAMSDBA> prompt.
  4. Enter GENERATE KEY Default and press Return.
  5. Enter EXPORT KEY YourFileName.txt Default and press Return.
  6. Enter EXIT and press Return.
  7. Move the exported text file to a safe location.

Restoring a Standalone JAMS Server​

When restoring a backup of the JAMS database to a different server, the encrypted passwords cannot be decrypted, because the protected copy of the key in the database is tied to the original machine. To restore the encryption key from a backup, follow these steps:

  1. Log on to the server as a user with "Execute" access to the JAMS configuration settings.
  2. Set the default directory to the JAMS Scheduler installation directory. The default is: C:\Program Files\MVPSI\JAMS\Scheduler
  3. Copy the exported text file (YourFileName.txt) from your safe location to the current directory. If the key was generated by the installer, this is the <database>-<machine>-EncryptionKey.txt file it saved.
  4. Execute JAMSDBA.EXE to open a JAMSDBA> prompt.
  5. Enter IMPORT KEY YourFileName.txt Default /NOENCRYPT and press Return.
  6. Enter EXIT and press Return.

Failover Environments​

Each node in a failover environment keeps its own DPAPI protected copy of the key, so the same key must be imported on the secondary. To protect the servers in a failover environment, follow the steps below:

  1. Make sure that your primary JAMS Server is in the running state.
  2. Log on to the primary server as a user with "Execute" access to the JAMS configuration settings.
  3. If the key was generated by the installer on the primary, skip to step 8 and use the file the installer saved (<database>-<machine>-EncryptionKey.txt). Do not run GENERATE KEY: it would replace the key, and the saved file would no longer match.
  4. Execute JAMSDBA.EXE to open a JAMSDBA> prompt.
  5. Enter GENERATE KEY Default and press Return.
  6. Enter EXPORT KEY YourFileName.txt Default and press Return.
  7. Enter EXIT and press Return.
  8. Move the exported text file to a safe location.
  9. Log on to the secondary server as a user with "Execute" access to the JAMS configuration settings.
  10. Make sure that Failover.config is in place on the secondary and that the JAMS Server service is running. See Installing and Configuring the JAMS Failover.
  11. Set your default directory to the JAMS Scheduler installation directory. The default is: C:\Program Files\MVPSI\JAMS\Scheduler
  12. Copy the exported text file (YourFileName.txt) from your safe location to the current directory.
  13. Execute JAMSDBA.EXE to open a JAMSDBA> prompt.
  14. Enter IMPORT KEY YourFileName.txt Default /NOENCRYPT and press Return.
  15. Enter EXIT and press Return.
note

GENERATE KEY does not run on the secondary node. Always generate the key on the primary, export it, and import it on the secondary.

caution

Whenever the key is changed on the primary, export it and repeat IMPORT KEY YourFileName.txt Default /NOENCRYPT on the secondary. Otherwise, the secondary cannot decrypt credentials after a failover.