How to resolve authtoken encryption error on APM Plugin Standby server in Failover?

How to resolve authtoken encryption error on APM Plugin Standby server in Failover?

Overview

After a failover switch in OpManager, the APM Plugin on the Standby server throws authtoken encryption errors and plugin functionalities such as monitoring, alerts, and data collection do not work.

Affected Version: APM Plugin build 179200 and above.
Note: This issue affects only the APM Plugin in Failover mode. Standalone APM installations are not affected.

How to Confirm ?

When accessing the Applications tab in OpManager UI, the following error is displayed:

Problem in fetching AuthToken from OpManager DB.
Hint: Applications Manager plugin might be facing an issue with connecting OpManager database.

The following errors also appear in the APM Plugin logs on the Standby server:

In <OPM_Home>\AppManager\logs\stderr.txt
java.lang.NullPointerException
at com.adventnet.appmanager.util.UserScopeUtil.getEARKeyForDBPoll(UserScopeUtil.java:513)
at com.adventnet.appmanager.util.UserScopeUtil.regenerateUserToken(UserScopeUtil.java:368)

java.lang.Exception: keyToken/plainText is invalid.
at com.adventnet.appmanager.util.AMEncryption.encrypt_AES_CBC_withKey(AMEncryption.java:293)

In <OPM_Home>\AppManager\logs\syncout.txt
PluginUtil.getPluginAuthTokenFromOpManagerDB() | EARKey is null |
Returning to avoid setting encrypted authtoken in cache

Cause

Both Primary and Standby APM Plugin servers share the same database, but each installation generates its own MasterEncryptionKey in <APM_Plugin_Home>\conf\DB_Crypt.properties. During failover, the Standby cannot decrypt data that was encrypted by the Primary's key, resulting in the errors above.

Root Cause: MasterEncryptionKey mismatch between Primary and Standby APM Plugin servers.

Resolution Steps

Ensure both Primary and Standby APM Plugin servers use the same MasterEncryptionKey so encrypted data in the shared database can be decrypted by either server.

A. Steps for Fresh Installation

For a freshly installed APM Plugin on the Standby server, the steps depend on whether the Standby server has already been started at least once.

Case 1: Standby server has NOT been started yet

If the Standby APM Plugin has never been started, DB_Crypt.properties does not exist yet. Perform these steps before starting the Standby server or triggering failover:

  1. Navigate to <APM_Plugin_Home>\conf\ on the Primary server.
  2. Copy the entire DB_Crypt.properties file.
  3. Place it in the same location <APM_Plugin_Home>\conf\ on the Standby server.
Why copy the entire file? Since the Standby server has not been started, DB_Crypt.properties does not exist — neither AMCryptKey nor MasterEncryptionKey have been generated. Copying the full file from Primary ensures both encryption keys are in sync from the start. No instance-specific data has been encrypted on Standby yet, so sharing the AMCryptKey does not cause any conflict.

Case 2: Standby server has already been started

If the Standby APM Plugin has been started at least once, DB_Crypt.properties already exists with its own unique AMCryptKey and MasterEncryptionKey. The AMCryptKey has already been used to encrypt instance-specific data (e.g., database passwords) on the Standby server. Only the MasterEncryptionKey needs to be synchronized:

  1. Open <APM_Plugin_Home>\conf\DB_Crypt.properties on the Primary server.
  2. Copy the value of MasterEncryptionKey.
  3. Open the same file on the Standby server.
  4. Replace the MasterEncryptionKey value with the one copied from Primary.
  5. Save the file.
Important: Do not replace the entire DB_Crypt.properties file or modify the AMCryptKey. The AMCryptKey is instance-specific — it has already been used to encrypt the Standby's local database passwords. Replacing it will cause the Standby to fail decrypting its own DB connection credentials.

B. Steps for Existing Installation (Post-Upgrade)

From build 179200, the MasterEncryptionKey is used for encrypting shared database data. Since each server already has its own different key, they must be synchronized. Copy the key from the server that was started first after the upgrade, as that server's key is used to encrypt data in the shared database:

How to determine which server started first? Check the APM Plugin logs on both servers:
  • <OPM_Home>\AppManager\logs\console1.txt
  • <OPM_Home>\AppManager\logs\StartUpLogs_out.txt
Compare the timestamps of the first startup entries after upgrade to identify which server was started first.
Prerequisite: After the upgrade completes and before replacing the key, take a backup of DB_Crypt.properties on both servers. This preserves the unique MasterEncryptionKey generated on each server during upgrade, and ensures the AMCryptKey can be restored in case the file is accidentally replaced instead of only updating the MasterEncryptionKey value.

If the Primary server was started first after upgrade:

  1. Open <APM_Plugin_Home>\conf\DB_Crypt.properties on the Primary server.
  2. Copy the value of MasterEncryptionKey.
  3. Open the same file on the Standby server.
  4. Replace the MasterEncryptionKey value with the one copied from Primary.
  5. Save the file.

If the Standby server was started first after upgrade:

  1. Open <APM_Plugin_Home>\conf\DB_Crypt.properties on the Standby server.
  2. Copy the value of MasterEncryptionKey.
  3. Open the same file on the Primary server.
  4. Replace the MasterEncryptionKey value with the one copied from Standby.
  5. Save the file.
Important: The MasterEncryptionKey must be copied from the server that was started first after upgrade, as that server's key is used to encrypt data in the shared database. Only replace the MasterEncryptionKey value — do not modify AMCryptKey or replace the entire file.
Note: This step needs to be performed only once after the first upgrade to the affected version. Subsequent upgrades do not require this step again.

Verification

After applying the fix, trigger a failover and confirm:

  1. The APM Plugin web console is accessible on the Standby server.
  2. No NullPointerException or "EARKey is null" errors in the logs.
  3. Monitors are active and collecting data.
Expected Result: APM Plugin starts without errors, web console is accessible, and monitoring resumes normally.

                    New to ADSelfService Plus?