1 Reply Latest reply on Apr 17, 2013 1:45 PM by JinZhao-Oracle

    com.sleepycat.db.Database.verify(), not working with encrypted db. bug?


      I have a berkeley database file encrypted with a password (In fact, there are two databases embedded in the same physical file). The Berkeley api version that I'm using is the 5.3.21:

      The databases work fine, and I can read all the encrypted data (in both databases)...

      However, if I try to verifiy the database with the method, com.sleepycat.db.Database.verify(), I get the following error...

      BDB0196 Encrypted checksum: no encryption key specified
      BDB0522 Page 0: metadata page corrupted
      BDB0196 Encrypted checksum: no encryption key specified
      BDB3016 C:\cneDir\env-cipher/inforep.db: pgin failed for page 0

      Even if setup the databaseConfig object with my password... This is the code that I'm using:
          private static void doVerify(String args[], String symmetricKey) {
              DatabaseConfig dbConfig;
              VerifyConfig verifyConfig;
              String filename;
              String dbName;
              boolean result;
              filename = args[0] + "/" + args[1];
              dbName   = args[2];
              dbConfig = new DatabaseConfig();
              System.out.println("Is encrypted: " + dbConfig.getEncrypted());
              verifyConfig = new VerifyConfig();
              try {
                  result = Database.verify(filename, dbName, System.out, verifyConfig, dbConfig);
                  System.out.println("Everything is OK? " + result);
              } catch (Exception ex) {
                  System.out.println("D OH!");
      This forced me to take the source code of the Java API to see what is happening...
      Atfer looking the API source code, it seems to me that the method com.sleepycat.db.Database.verify(), never sets the password at any point of its execution... So, I take the source code and I modify the method to set my password (Hardcoded):
          public static boolean verify(final String fileName,
                                       final String databaseName,
                                       final java.io.PrintStream dumpStream,
                                       VerifyConfig verifyConfig,
                                       DatabaseConfig dbConfig)
              throws DatabaseException, java.io.FileNotFoundException {
              final Db db = DatabaseConfig.checkNull(dbConfig).createDatabase(null);
              db.set_encrypt("1234", DbConstants.DB_ENCRYPT_AES);   //Here, 1234 is my password
              return db.verify(fileName, databaseName, dumpStream,
      Atfer this modification, the method com.sleepycat.db.Database.verify() returns true and doesn't throw any exception. So, I'm guessing that this could be a bug, right??