Invalid Master Key in BES 5.0

Had an interesting problem when trying to add a new Enterprise CAL key to a BES 5.0.3 where I would see the Invalid master key error.

Problem

When trying to add a new Enterprise license key to the BES server I would be presented with “The request could not be completed” error.

Invalid master key

Looking at the event logs, the one that caught this error was the BBAS-AS log. Specifically, I would see the following stack trace error:

com.rim.bes.bas.licensemanagertools.LicenseManagerJNIException: BAS LicenseManager exception occurred in function: JLicenseManager::constructNewMasterKey, Error: -9 - Invalid Master Key
 at com.rim.bes.bas.licensemanagertools.LicenseManagerAccessorImpl.constructNewMasterKeyJNI(Native Method)
 at com.rim.bes.bas.licensemanagertools.LicenseManagerAccessorImpl.constructNewMasterKey(LicenseManagerAccessorImpl.java:559)

Cause

The issue was escalated to the vendor who responded that one of the existing license keys was of SMB type (not Enterprise) and was causing the problem. This is also documented on their website as KB18732.

Solution – fixing Invalid Master Key error

RIM provided a SQL script to remove the license key, although I suspect this could be manually done as well.

Be sure to stop the BAS-AS and BAS-NCC services and backup your BES database before running the script!

/*+---------------------------------------------------------------------------
*  Support Script: DeleteCalFromDatabase
*  Created: 3/17/2010
*  Tracked via : <removed>
*  Description: Delete a CAL from the Database.
*
*  Instructions for running script:
*      1.  Backup database
*      2.  In SQL Server Management, select the BES configuration database
*      3.  Change the @Cal within the Edit section to the CAL you wish to remove
*      4.  Run the script
*+--------------------------------------------------------------------------*/

USE <name of your BES database>

DECLARE @Cal NVARCHAR(256)

/*----------------------------------------------------------------------------*/
/*      Edit this section only                                                */
/*----------------------------------------------------------------------------*/

SET @Cal = 'besx …'  -- the CAL you wish to remove

/*----------------------------------------------------------------------------*/
/*      End of editable section                                               */
/*----------------------------------------------------------------------------*/

DELETE FROM LicenseKeys WHERE LicenseKey = @Cal
GO

Once I removed the SMB license key, adding the new licenses worked perfectly. Unfortunately the Invalid Master key error does not seem to be documented anywhere so RIM should update their KB article with additional details.