lib/db/je7enc/je-7.5.11-ragic.jar
If the file does not exist, update to a Ragic patch that supports database encryption, and verify again after updating.
2. Verify the Encryption Startup Scripts
Verify that the following files exist in the Ragic installation directory:
• Linux
bin/ragic_dbv7enc.sh bin/setclasspath_dbv7enc.sh• Windows
bin/ragic_dbv7enc.bat bin/setclasspath_dbv7enc.batIf either file is missing, download the full installation package that matches your current Ragic version, extract it to a temporary directory, and copy the missing files to the bin folder of your existing installation. These two startup scripts are not included in patches.
# RagicHome: the Ragic installation directory. Set this value for your environment first # Set the read and execute permissions of the startup scripts chmod 755 -- "$RagicHome/bin/ragic_dbv7enc.sh" "$RagicHome/bin/setclasspath_dbv7enc.sh"3. Verify the System Is Running Normally
# Allow only the current user to access newly created files umask 077 # Generate a 256-bit key and write it to the dedicated key folder you created openssl rand -hex -out /mnt/ragic-key/ragic/db-master.key 32• Windows (PowerShell)
openssl rand -hex -out E:/RagicKey/db-master.key 32
This command generates a 256-bit random key and writes it to the file as 64 hexadecimal characters.
2. Set File Permissions
Have someone with administrator privileges set the owner of the key file to the user account that actually runs Ragic on the operating system, and remove access for all users who do not need it.
• Linux
Set the owner of the key file and the dedicated key folder to the user account that actually runs Ragic. Set the key file permission to 600 and the folder permission to 700, and make sure that account can traverse all parent directories to read the key.
# RagicServiceUser: the Linux user account that actually runs Ragic. Set this value for your environment first # Give ownership of the key folder and key file to the Ragic service account chown -- "$RagicServiceUser" /mnt/ragic-key/ragic /mnt/ragic-key/ragic/db-master.key # Allow only the owner to access the folder chmod 700 -- /mnt/ragic-key/ragic # Allow only the owner to read and write the key file chmod 600 -- /mnt/ragic-key/ragic/db-master.key• Windows
DB_ENCRYPTION_ACCOUNTS= DB_ENCRYPTION_MASTER_KEY=file:/mnt/ragic-key/ragic/db-master.key• Windows
DB_ENCRYPTION_ACCOUNTS= DB_ENCRYPTION_MASTER_KEY=file:E:/RagicKey/db-master.keyLeave the value of DB_ENCRYPTION_ACCOUNTS blank for now, but the key must exist, and it must be placed before the key line in this order. After file:, use the actual absolute path with forward slashes and no quotation marks.
Log encryption master key version 1 fingerprint 【full fingerprint, 32 hexadecimal characters】 (record it as DB_ENCRYPTION_MASTER_KEY_FINGERPRINT in conf/ragic.properties to have a wrong key refused)
• Windows
Log encryption master key version 1 fingerprint 【full fingerprint, 32 hexadecimal characters】 (record it as DB_ENCRYPTION_MASTER_KEY_FINGERPRINT in conf\ragic.properties to have a wrong key refused)
Stop the Ragic service, enter the fingerprint you recorded in Step 2 in the configuration file, and keep the original key source:
• Linux
DB_ENCRYPTION_ACCOUNTS= DB_ENCRYPTION_MASTER_KEY=file:/mnt/ragic-key/ragic/db-master.key DB_ENCRYPTION_MASTER_KEY_FINGERPRINT=【full fingerprint recorded in Step 2】• Windows
DB_ENCRYPTION_ACCOUNTS= DB_ENCRYPTION_MASTER_KEY=file:E:/RagicKey/db-master.key DB_ENCRYPTION_MASTER_KEY_FINGERPRINT=【full fingerprint recorded in Step 2】Restart Ragic the same way you did in Step 2, and confirm that this startup's log no longer shows the prompt to record the fingerprint and has no key provider errors.
DB_ENCRYPTION_ACCOUNTS=default
An On-premises Private Server includes the account database (ragic) and the user database (default) by default. To also encrypt the account database, separate the names with a semicolon. For example:
DB_ENCRYPTION_ACCOUNTS=default;ragic
If you set both default and ragic, you must also complete the conversion of both databases in Step 5.
After saving the changes, start the Ragic service with ragic_dbv7enc.sh (Linux) or ragic_dbv7enc.bat (Windows), confirm that data can be opened, written, and read back, and then stop the service.
At this point, only newly created database files are encrypted. You must still complete the conversion in Step 5 for existing files before the full encryption is complete.
In this step, you export the existing data and load it into a new encrypted database. After verification, you replace the original database with the new one.
Ragic must stay stopped during this step.
Use a separate working directory for each database you want to encrypt. For example, default and ragic must be handled separately.
The following uses default as an example. Adjust the paths and database names for your environment, and run the following commands in order in the same Bash session (Linux) or PowerShell window (Windows):
• Linux
# Stop on unhandled command errors. You still need to check the error messages of each JE tool
set -e
# Allow only the current user to access the newly created working directory and export files
umask 077
# RagicHome: the Ragic installation directory. Set this value for your environment first
# MigrationDir: root path of the working directory for this conversion, used to store export files and the new encrypted data
# Name of the Ragic database directory to encrypt in this run, such as default or ragic
AccountName='default'
# Source database directory, composed of the installation directory and the database name
EnvHome="$RagicHome/cust/data/$AccountName"
# Working directory for this database conversion. Use a different path for each database
WorkDir="$MigrationDir/$AccountName/main"
# Stores the reloaded encrypted data
NewEnv="$WorkDir/encrypted"
# Stores the export files from before and after the conversion, for comparing contents
DumpDir="$WorkDir/dump"
# Use a brand-new working directory to avoid mixing in data from earlier conversions
if [ -e "$WorkDir" ]; then
echo 'The working directory already exists. Verify it and use a new directory.' >&2
exit 1
fi
# Create the directories for the new encrypted data and the export files
mkdir -p -- "$NewEnv" "$DumpDir"
• Windows (PowerShell)
# $RagicHome: the Ragic installation directory
# $MigrationDir: root path of the working directory for this conversion, used to store export files and the new encrypted data
# Name of the Ragic database directory to encrypt in this run, such as default or ragic
$AccountName = 'default'
# Source database directory, composed of the installation directory and the database name
$EnvHome = Join-Path $RagicHome "cust\data\$AccountName"
# Working path for this database's main directory. Use a different path for each database
$WorkDir = Join-Path $MigrationDir "$AccountName\main"
# Stores the reloaded encrypted data
$NewEnv = Join-Path $WorkDir 'encrypted'
# Stores the export files from before and after the conversion, for comparing contents
$DumpDir = Join-Path $WorkDir 'dump'
# Use a brand-new working directory to avoid mixing in data from earlier conversions
if (Test-Path -LiteralPath $WorkDir) {
throw 'The working directory already exists. Verify it and use a new directory.'
}
# Create the directories for the new encrypted data and the export files
New-Item -ItemType Directory -Path $NewEnv, $DumpDir | Out-Null
Set the parameters used by the encryption tools, and enable encryption in the new directory:# Java startup parameter array shared by the JE tools that follow
# "${JeArgs[@]}" expands this set of parameters item by item when a tool is called
JeArgs=(
'-Dje.log.encryption.keyProvider=com.sleepycat.je.log.PropertiesFileKeyProvider'
"-Dje.log.encryption.propertiesFile=$RagicHome/conf/ragic.properties"
'-cp' "$RagicHome/lib/db/je7enc/je-7.5.11-ragic.jar"
)
# Explicitly require the new directory to produce encrypted files
printf '%s\n' 'je.log.encryption.encryptNewFiles=true' > "$NewEnv/je.properties"
• Windows (PowerShell)
# Java startup parameter array shared by the JE tools that follow
# @JeArgs expands this set of parameters when a tool is called
$JeArgs = @(
'-Dje.log.encryption.keyProvider=com.sleepycat.je.log.PropertiesFileKeyProvider'
"-Dje.log.encryption.propertiesFile=$RagicHome\conf\ragic.properties"
'-cp', "$RagicHome\lib\db\je7enc\je-7.5.11-ragic.jar"
)
# Explicitly require the new directory to produce encrypted files
Set-Content -LiteralPath "$NewEnv\je.properties" -Encoding Ascii `
-Value 'je.log.encryption.encryptNewFiles=true'
Note: Export files contain plaintext data that can be restored. Control access to them carefully.
# JavaBin: full path of the Java executable used to start Ragic. Set this value for your environment first
# List the names of all internal JE databases in the source directory
# Every name in the list must be converted and compared separately in the steps that follow
"$JavaBin" "${JeArgs[@]}" com.sleepycat.je.util.DbDump -h "$EnvHome" -l
• Windows (PowerShell)
# $JavaBin: full path of the Java executable used to start Ragic # List the names of all internal JE databases in the source directory # Every name in the list must be converted and compared separately in the steps that follow & $JavaBin @JeArgs com.sleepycat.je.util.DbDump -h $EnvHome -lEvery name in the list must be processed. The following uses one of the names, p, as an example, exporting it and loading it into the new directory:
# Specify the internal database name for this run. This example uses p from the list
DbName='p'
# Path of the file exported from the original database
Before="$DumpDir/$DbName.before.dump"
# Path of the file re-exported from the new encrypted database
After="$DumpDir/$DbName.after.dump"
# Export the specified internal database from the original database
"$JavaBin" "${JeArgs[@]}" com.sleepycat.je.util.DbDump -h "$EnvHome" -s "$DbName" -f "$Before"
# Load the exported data into the new directory with encryption enabled
"$JavaBin" "${JeArgs[@]}" com.sleepycat.je.util.DbLoad -h "$NewEnv" -s "$DbName" -f "$Before"
• Windows (PowerShell)
# Specify the internal database name for this run. This example uses p from the list $DbName = 'p' # Path of the file exported from the original database $Before = Join-Path $DumpDir "$DbName.before.dump" # Path of the file re-exported from the new encrypted database $After = Join-Path $DumpDir "$DbName.after.dump" # Export the specified internal database from the original database & $JavaBin @JeArgs com.sleepycat.je.util.DbDump -h $EnvHome -s $DbName -f $Before # Load the exported data into the new directory with encryption enabled & $JavaBin @JeArgs com.sleepycat.je.util.DbLoad -h $NewEnv -s $DbName -f $BeforeThen export the same internal database from the new directory, and compare the contents from before and after the conversion:
# Re-export the same internal database from the new directory
"$JavaBin" "${JeArgs[@]}" com.sleepycat.je.util.DbDump -h "$NewEnv" -s "$DbName" -f "$After"
# Calculate the SHA-256 of both export files
# The hashes of the two files must be identical to confirm that the exported contents are the same before and after the conversion
sha256sum -- "$Before" "$After"
• Windows (PowerShell)
# Re-export the same internal database from the new directory & $JavaBin @JeArgs com.sleepycat.je.util.DbDump -h $NewEnv -s $DbName -f $After # Calculate the SHA-256 of both export files # The hashes of the two files must be identical to confirm that the exported contents are the same before and after the conversion Get-FileHash -LiteralPath $Before, $After -Algorithm SHA256The hashes of the two files should be identical, and the last line of each export file should be DATA=END.
# List the internal database names in the new directory and confirm they match the source list
"$JavaBin" "${JeArgs[@]}" com.sleepycat.je.util.DbDump -h "$NewEnv" -l
• Windows (PowerShell)
# List the internal database names in the new directory and confirm they match the source list & $JavaBin @JeArgs com.sleepycat.je.util.DbDump -h $NewEnv -lCheck the integrity of the database files:
# Verify the integrity of all JE log files in the new directory
"$JavaBin" "${JeArgs[@]}" com.sleepycat.je.util.DbVerifyLog -h "$NewEnv"
• Windows (PowerShell)
# Verify the integrity of all JE log files in the new directory & $JavaBin @JeArgs com.sleepycat.je.util.DbVerifyLog -h $NewEnvCheck the encryption status of each file. The following command lists only the file header records:
# List only the file header records to check whether each file has the encryption flag
# -ty 25 specifies the FileHeader record type
# Every file header should contain encrypted="true"
"$JavaBin" "${JeArgs[@]}" com.sleepycat.je.util.DbPrintLog -h "$NewEnv" -ty 25
• Windows (PowerShell)
# List only the file header records to check whether each file has the encryption flag # -ty 25 specifies the FileHeader record type # Every file header should contain encrypted="true" & $JavaBin @JeArgs com.sleepycat.je.util.DbPrintLog -h $NewEnv -ty 25Every file header should contain:
encrypted="true"
Switch over only after all checks pass.
After confirming that all databases are converted and verified, keep Ragic stopped and perform the following in order:
1. Keep the original files
Move all .jdb files in the original database directory ($EnvHome) to a separate backup directory. Store each database's files separately, and keep them until post-startup verification is complete.
2. Put the encrypted files in place
Copy all .jdb files in the new encrypted directory ($NewEnv) back to the original database directory ($EnvHome). Replace the whole set. Do not mix .jdb files from before and after the conversion.
3. Keep the other files
Leave attachments, search indexes, and other non-.jdb files in the original directory as they are. The je.properties file in the new encrypted directory is used only for the conversion and does not need to be copied back.
4. Verify the files and permissions
Confirm that the list and contents of the copied .jdb files match the new encrypted directory, and that the operating system account that runs Ragic has read and write permission.
If you are processing multiple databases (for example, default and ragic), complete the steps above for each directory, and then start Ragic and perform the verification in Step 6.
If an error occurs during the switch, keep Ragic stopped and start it again only after all files are fully restored.
After switching all databases, start Ragic with ragic_dbv7enc.sh (Linux) or ragic_dbv7enc.bat (Windows), and confirm the following in order:
1. Log in normally, and confirm that the databases and forms open normally.
2. Open existing entries, and confirm that data and attachments can be read normally and that search works.
3. Create a test entry, enter RAGIC_ENCRYPTION_TEST_12345678 in a text field, save it, reopen it, and confirm that the content is correct.
4. Stop Ragic normally, search the production database that stores the test entry as described in Raw File String Check below, and confirm that the test string cannot be found in the raw .jdb files.
5. Restart Ragic, and confirm again that both the existing entries and the new test entry can be read.
6. Check the Log encryption messages in log/ragic.out since this startup, as well as log/BDBMgr.txt. If log/dbEncryption.log was generated, also check whether ENCRYPTION REFUSAL appears. Confirm that there are no encryption errors or database open, read, or write errors.
Run this check after stopping Ragic in item 4, and make sure $EnvHome points to the production database directory that stores the test entry. This check uses a test string made up of English letters, numbers, and underscores. If you use a different string, the entry content and $TestText below must match exactly, including capitalization.
• Linux
# EnvHome: production database directory that stores the test entry, such as cust/data/default
# The string written to the test entry. It must match the entry content exactly
TestText='RAGIC_ENCRYPTION_TEST_12345678'
# All .jdb files to check. If there are no files, the array stays empty
shopt -s nullglob
JdbFiles=("$EnvHome"/*.jdb)
if [ "${#JdbFiles[@]}" -eq 0 ]; then
echo 'No .jdb files found. Verify the production database directory.' >&2
exit 1
fi
# Treat the files as raw text and search for the fixed string, case-sensitive. When found, list only the file path
if grep -aFl -- "$TestText" "${JdbFiles[@]}"; then
echo 'Test string found. Stop the verification and find out why.' >&2
exit 1
else
# GrepStatus: exit code of grep. 1 means the string was not found; any other non-zero value indicates an error
GrepStatus=$?
if [ "$GrepStatus" -ne 1 ]; then
echo 'The string search failed and cannot be treated as a pass.' >&2
exit 1
fi
fi
• Windows (PowerShell)
# Stop the check on file enumeration or read errors
$ErrorActionPreference = 'Stop'
# $EnvHome: production database directory that stores the test entry, such as cust/data/default
# The string written to the test entry. It must match the entry content exactly
$TestText = 'RAGIC_ENCRYPTION_TEST_12345678'
# All .jdb files to check
$JdbFiles = @(Get-ChildItem -LiteralPath $EnvHome -File -Filter '*.jdb')
if ($JdbFiles.Count -eq 0) {
throw 'No .jdb files found. Verify the production database directory.'
}
# $File is the file being checked. Read the raw bytes directly and search for the ASCII test string
# When found, list only the file path and do not output the file contents
foreach ($File in $JdbFiles) {
if ([System.Text.Encoding]::ASCII.GetString([System.IO.File]::ReadAllBytes($File.FullName)).Contains($TestText)) {
$File.FullName
}
}
If a file path is listed, the test string was found. The check found no string only when there is no output and no errors. If the string is found or an error occurs, stop the verification and find out why before continuing.# Stop on unhandled command errors. You still need to check the error messages of each JE tool
set -e
# Allow only the current user to access the newly created working directory and export files
umask 077
# RagicHome: the Ragic installation directory. Set this value for your environment first
# JavaBin: full path of the Java executable used to start Ragic. Set this value for your environment first
# MigrationDir: root path of the rollback working directory, used to store export files and the new plaintext database
# Name of the Ragic database directory to roll back in this run
AccountName='default'
# Production database directory to convert back to plaintext
EnvHome="$RagicHome/cust/data/$AccountName"
# Separate working directory for this rollback
WorkDir="$MigrationDir/$AccountName/rollback/main"
# Stores the reloaded plaintext database
NewEnv="$WorkDir/plain"
# Stores the export files from before and after the rollback, for comparing contents
DumpDir="$WorkDir/dump"
# Use a brand-new working directory to avoid mixing in data from earlier runs
if [ -e "$WorkDir" ]; then
echo 'The rollback working directory already exists. Verify it and use a new directory.' >&2
exit 1
fi
# Create the directories for the new plaintext database and the export files
mkdir -p -- "$NewEnv" "$DumpDir"
• Windows (PowerShell)
# $RagicHome: the Ragic installation directory
# $JavaBin: full path of the Java executable used to start Ragic
# $MigrationDir: root path of the rollback working directory, used to store export files and the new plaintext database
# Name of the Ragic database directory to roll back in this run
$AccountName = 'default'
# Production database directory to convert back to plaintext
$EnvHome = Join-Path $RagicHome "cust\data\$AccountName"
# Separate working directory for this rollback
$WorkDir = Join-Path $MigrationDir "$AccountName\rollback\main"
# Stores the reloaded plaintext database
$NewEnv = Join-Path $WorkDir 'plain'
# Stores the export files from before and after the rollback, for comparing contents
$DumpDir = Join-Path $WorkDir 'dump'
# Use a brand-new working directory to avoid mixing in data from earlier runs
if (Test-Path -LiteralPath $WorkDir) {
throw 'The rollback working directory already exists. Verify it and use a new directory.'
}
# Create the directories for the new plaintext database and the export files
New-Item -ItemType Directory -Path $NewEnv, $DumpDir | Out-Null
Set the startup parameters for the encryption tools and the original JE tools separately:# Java startup parameters for the encryption tools, used to read the original encrypted database
# "${JeArgs[@]}" expands this set of parameters item by item and obtains the key and fingerprint through the original configuration file
JeArgs=(
'-Dje.log.encryption.keyProvider=com.sleepycat.je.log.PropertiesFileKeyProvider'
"-Dje.log.encryption.propertiesFile=$RagicHome/conf/ragic.properties"
'-cp' "$RagicHome/lib/db/je7enc/je-7.5.11-ragic.jar"
)
# Java startup parameters for the original JE tools, used to load and verify the new plaintext database
# "${PlainJeArgs[@]}" expands this set of parameters item by item and loads only the original JE JAR
PlainJeArgs=('-cp' "$RagicHome/lib/db/je7/je-7.5.11.jar")
• Windows (PowerShell)
# Java startup parameters for the encryption tools, used to read the original encrypted database
# @JeArgs expands this set of parameters and obtains the key and fingerprint through the original configuration file
$JeArgs = @(
'-Dje.log.encryption.keyProvider=com.sleepycat.je.log.PropertiesFileKeyProvider'
"-Dje.log.encryption.propertiesFile=$RagicHome\conf\ragic.properties"
'-cp', "$RagicHome\lib\db\je7enc\je-7.5.11-ragic.jar"
)
# Java startup parameters for the original JE tools, used to load and verify the new plaintext database
# @PlainJeArgs expands this set of parameters and loads only the original JE JAR
$PlainJeArgs = @('-cp', "$RagicHome\lib\db\je7\je-7.5.11.jar")
Keep the new plaintext directory brand new. Do not put the je.properties encryption configuration file used in Step 5 in it.# Use the encryption tools to list the names of all internal databases in the source
"$JavaBin" "${JeArgs[@]}" com.sleepycat.je.util.DbDump -h "$EnvHome" -l
• Windows (PowerShell)
# Use the encryption tools to list the names of all internal databases in the source & $JavaBin @JeArgs com.sleepycat.je.util.DbDump -h $EnvHome -lEvery name in the list must go through the following export, load, and comparison separately. The following uses p as an example:
# Internal database name for this run. Adjust it for each name in the source list
DbName='p'
# Plaintext file exported from the original encrypted database
Before="$DumpDir/$DbName.before.dump"
# File re-exported from the new plaintext database
After="$DumpDir/$DbName.after.dump"
# Use the encryption tools to read and export the source data
"$JavaBin" "${JeArgs[@]}" com.sleepycat.je.util.DbDump -h "$EnvHome" -s "$DbName" -f "$Before"
# Use the original JE to load the data into the new plaintext directory
"$JavaBin" "${PlainJeArgs[@]}" com.sleepycat.je.util.DbLoad -h "$NewEnv" -s "$DbName" -f "$Before"
• Windows (PowerShell)
# Internal database name for this run. Adjust it for each name in the source list $DbName = 'p' # Plaintext file exported from the original encrypted database $Before = Join-Path $DumpDir "$DbName.before.dump" # File re-exported from the new plaintext database $After = Join-Path $DumpDir "$DbName.after.dump" # Use the encryption tools to read and export the source data & $JavaBin @JeArgs com.sleepycat.je.util.DbDump -h $EnvHome -s $DbName -f $Before # Use the original JE to load the data into the new plaintext directory & $JavaBin @PlainJeArgs com.sleepycat.je.util.DbLoad -h $NewEnv -s $DbName -f $BeforeThen use the original JE to export the same internal database, and confirm that the contents match:
# Use the original JE to re-export the data from the new plaintext database
"$JavaBin" "${PlainJeArgs[@]}" com.sleepycat.je.util.DbDump -h "$NewEnv" -s "$DbName" -f "$After"
# Calculate the SHA-256 of the export files from before and after the rollback. The hashes of the two files must be identical
sha256sum -- "$Before" "$After"
• Windows (PowerShell)
# Use the original JE to re-export the data from the new plaintext database & $JavaBin @PlainJeArgs com.sleepycat.je.util.DbDump -h $NewEnv -s $DbName -f $After # Calculate the SHA-256 of the export files from before and after the rollback. The hashes of the two files must be identical Get-FileHash -LiteralPath $Before, $After -Algorithm SHA256The hashes of the two files must be identical, and the last line of each export file must be DATA=END. After each command, confirm that there are no error messages. Do not rely on the exit code alone to determine success. If there is an error or the comparison does not match, stop and do not switch the production data.
# Use the original JE to list the internal databases in the new plaintext directory and confirm they match the source list
"$JavaBin" "${PlainJeArgs[@]}" com.sleepycat.je.util.DbDump -h "$NewEnv" -l
# Use the original JE to verify all log files in the new plaintext directory
"$JavaBin" "${PlainJeArgs[@]}" com.sleepycat.je.util.DbVerifyLog -h "$NewEnv"
• Windows (PowerShell)
# Use the original JE to list the internal databases in the new plaintext directory and confirm they match the source list & $JavaBin @PlainJeArgs com.sleepycat.je.util.DbDump -h $NewEnv -l # Use the original JE to verify all log files in the new plaintext directory & $JavaBin @PlainJeArgs com.sleepycat.je.util.DbVerifyLog -h $NewEnvSwitch over only after confirming that there are no error messages. Every database directory that contains encrypted files must go through the processing above separately.