By default, OBLOADER & OBDUMPER can run after you explicitly specify sensitive information such as the password on the command line. To enhance information security, OBLOADER & OBDUMPER V4.2.0 and later provide methods to encrypt and decrypt sensitive information on the command line.
Quick start: Encrypt credentials with secure-gen
OBLOADER & OBDUMPER V5.0.0 can store passwords for multiple business accounts and sys tenant accounts in a single encrypted file. Passwords are matched by username, tenant name, cluster name, host address, and port.
Configure passwords and generate an encrypted file
Install OpenSSL and configure the environment variables. Run the following command to verify that the system can find OpenSSL.
$ which openssl /usr/bin/opensslConfigure passwords for the required accounts. The following example defines two business accounts. Replace the sample passwords with actual values.
oceanbase.jdbc.password.core_user=CORE_PASSWORD oceanbase.jdbc.password.loan_user=LOAN_PASSWORDIn the
{ob-loader-dumper}/tools/directory, use either of the following methods to generate an encrypted file. The configuration must follow the Properties File Format.From a file: Save the configuration to
passwords.propertiesand run the following command../secure-gen -n /path/to/passwords.propertiesInteractively: Run the following command, enter the configuration in
vi, press Esc, and enter:wqto save and exit../secure-gen -i
The following table lists the properties for passwords and other sensitive information. For account identifier formats and matching order, see "Credential matching rules for multiple accounts" below.
PropertyDescriptionoceanbase.jdbc.password.<account_identifier>Business account password, corresponding to -por--passwordon the command line.oceanbase.jdbc.sys.password.<account_identifier>sys tenant account password, corresponding to --sys-passwordon the command line.oceanbase.jdbc.passwordDefault business account password. Used only when no business account password properties include an account identifier. oceanbase.jdbc.sys.passwordDefault sys tenant password. Used only when no sys tenant password properties include an account identifier. oceanbase.jdbc.trustStorePasswordtrustStore password for SSL connections. Not matched by account. oceanbase.jdbc.keyStorePasswordkeyStore password for SSL connections. Not matched by account. cloud.storage.access.keyCloud storage account access key ( access-key). Not matched by account.cloud.storage.secret.keyCloud storage secret access key ( secret-key). Not matched by account.Keep the following in mind:
- Property names are case-sensitive. Password values do not require quotation marks. Escape backslashes, as well as special characters in property names, according to Properties syntax.
- An empty value specifies an empty password, as in
oceanbase.jdbc.password.empty_user=. It does not mean that the account is unconfigured. - If a property name appears more than once, the last entry takes effect. Do not use duplicate property names for different accounts.
- When creating or regenerating keys, the entire plaintext file must not exceed 1920 bytes, including comments and line breaks. When reusing keys, the limit depends on the actual key capacity. Keep only the required content; do not encrypt the full
conf/secure-passwords.example.propertiesfile.
If a key pair already exists, choose whether to reuse it when prompted.
- Enter
yto reuse the key pair and regeneratesecure.rsa. If the plaintext file exceeds the size limit for the existing key, the tool returns an error and preserves the existing credentials. Reduce the file size. If the file is no larger than 1920 bytes, you can also rerun the command and choosento try regenerating the keys. - Enter
nto regenerate the key pair and encrypted file. Before doing so, pause the launch of new import and export tasks. The tool backs up the existing credentials and displays the backup directory.
The key pair and encrypted file are stored in
~/.loaddump/secure/under the current operating system user. The public key iskey.pem.pub, the private key iskey.pem, and the encrypted file issecure.rsa.- Enter
After encryption succeeds, verify that the output directory contains the following three files.
$ ls ~/.loaddump/secure/ key.pem key.pem.pub secure.rsaSpecify the absolute paths to the encrypted file and private key in
{ob-loader-dumper}/conf/security.properties. For example:encrypt.filePath=/home/admin/.loaddump/secure/secure.rsa secretKey.filePath=/home/admin/.loaddump/secure/key.pemReplace the sample paths with actual paths. When using secure-gen, leave
security.classNameempty or comment it out.The legacy properties
secure.filePathandprivateKey.filePathare still supported. They correspond toencrypt.filePathandsecretKey.filePath, respectively. We recommend using the new properties.In the
{ob-loader-dumper}/bin/directory, run OBLOADER or OBDUMPER with the corresponding account and omit the password options already configured. For example, export data with the two accounts configured earlier:./obdumper -h 10.0.0.11 -P 2881 -u core_user -t obmysql -D core_db --csv --all -f /data/core_export ./obdumper -h 10.0.0.11 -P 2881 -u loan_user -t obmysql -D loan_db --csv --all -f /data/loan_exportUse actual accounts with the required privileges, and replace the connection parameters and export directories to suit your environment. If the task requires a sys connection, also provide the sys tenant account password. OBLOADER uses the same credential matching rules.
Credential matching rules for multiple accounts
Account identifiers support the following formats. You can restrict an entry to a tenant, cluster, or connection address as needed:
username
username@tenant
username@tenant#cluster
username|host|port
username@tenant|host|port
username@tenant#cluster|host|port
The following example configures different passwords for users with the same name at different addresses, plus a password for a sys tenant account:
oceanbase.jdbc.password.root@obmysql|10.0.0.11|2881=IP11_PASSWORD
oceanbase.jdbc.password.root@obmysql|10.0.0.12|2881=IP12_PASSWORD
oceanbase.jdbc.sys.password.root@sys|10.0.0.11|2881=SYS_IP11_PASSWORD
- Business account identifiers use the username, tenant name, and cluster name parsed from
-u,-t, and-c. Both-u user@tenant#clusterand-u user -t tenant -c clustercan match the same entry. - The sys user is specified by
--sys-userand defaults toroot. The tenant used for matching is alwayssys. Matching occurs only when a sys connection is required and its password must be read from the encrypted file. It is skipped when--no-sysis specified. - With
--public-cloudor--logical-database, business account matching uses the username and optional address restriction, without the tenant or cluster parts. - The host address must exactly match
-h. Matching is case-sensitive and does not perform DNS resolution. Specify the port in the property name as a decimal integer without leading zeros, such as2881. |is a reserved separator and cannot appear in usernames or hostnames. Escape colons in IPv6 addresses according to Properties syntax.
Passwords specified by -p or --sys-password take precedence. If the value is empty or contains only whitespace, the password is still read from the credential configuration.
When using an encrypted file, entries with a host and port are checked before entries without an address. Within each group, the order is username + tenant + cluster, username + tenant, then username. For a business connection that specifies a tenant, cluster, and address, the matching order is:
oceanbase.jdbc.password.username@tenant#cluster|host|port
oceanbase.jdbc.password.username@tenant|host|port
oceanbase.jdbc.password.username|host|port
oceanbase.jdbc.password.username@tenant#cluster
oceanbase.jdbc.password.username@tenant
oceanbase.jdbc.password.username
If no tenant or cluster is specified, entries that require it are skipped. The first matching value is used. sys tenant passwords follow the same order, with the prefix oceanbase.jdbc.sys.password and tenant sys.
Compatibility and migration
Business account passwords and sys tenant passwords are handled independently:
- If no password properties include an account identifier, the corresponding default property is used:
oceanbase.jdbc.passwordoroceanbase.jdbc.sys.password. - Adding a password property with an account identifier enables configuration for multiple accounts in that category. When a password is read from the encrypted file, failure to match the current connection returns an error; the tool does not fall back to the default password.
- The two categories are independent. For example, business accounts can use multiple-account configuration while the sys tenant still uses the default password property. TLS and cloud storage properties do not affect which mode is used.
To migrate, add entries for all accounts that need to read passwords from the encrypted file, then encrypt the file again.
View secure-gen help
secure-gen is an executable shell script in {ob-loader-dumper}/tools/ that uses RSA to encrypt sensitive information. At runtime, OBLOADER & OBDUMPER use conf/security.properties to locate the encrypted file and private key, then decrypt and read the credentials.
Run ./secure-gen -h or ./secure-gen without arguments to view help:
$ ./secure-gen -h
Usage: ./secure-gen [-n <file>][-i][-h]
-n: Encrypt a properties file; use -i to see the format.
-i: Edit sensitive properties interactively.
-h: Display this message.
Advanced usage: Use custom encryption and decryption
You can write a Java decryption class to read password configurations encrypted with your own mechanism, without OpenSSL.
Encrypt a password configuration in Properties format and save it to a file.
Write a public Java decryption class with a public no-argument constructor and the non-static method
public String security(String encryptedRaw). This method receives the encrypted file contents and returns the plaintext configuration in Properties format.Package the decryption class into a JAR file and place it in
{ob-loader-dumper}/lib/.In
{ob-loader-dumper}/conf/security.properties, setencrypt.filePathto the file path andsecurity.classNameto the fully qualified name of the decryption class.
Example
The following example uses Base64 to demonstrate the custom decryption interface. Base64 encoding does not provide encryption protection. Use an appropriate encryption and decryption algorithm in production.
Create
password.txtwith the following password configuration. Replace the sample passwords with actual values.oceanbase.jdbc.password=BUSINESS_PASSWORD oceanbase.jdbc.sys.password=SYS_PASSWORDEncode the file and save it as
custom.key. Replace the sample path to suit your environment, and use the same path in the subsequent configuration.mkdir -p /user/loaddump base64 < password.txt > /user/loaddump/custom.keyCreate a Maven project. In the project structure below,
CustomDecryptor.javais the custom decryption class to implement.
Implement the
CustomDecryptorclass.package com.example.decrypt; import java.nio.charset.StandardCharsets; import java.util.Base64; public class CustomDecryptor { public CustomDecryptor() {} public String security(String encryptedRaw) { byte[] decoded = Base64.getMimeDecoder().decode(encryptedRaw); return new String(decoded, StandardCharsets.UTF_8); } }Package the
CustomDecryptorclass into a JAR file and place it in{ob-loader-dumper}/lib/.mvn package cp target/example-1.0-SNAPSHOT.jar /path/to/ob-loader-dumper/lib/Replace the sample JAR filename and tool path with actual values.
Set the following properties in
{ob-loader-dumper}/conf/security.properties.encrypt.filePath=/user/loaddump/custom.key security.className=com.example.decrypt.CustomDecryptorCustom decryption does not read
secretKey.filePath, so you can omit this property.In the
{ob-loader-dumper}/bin/directory, run OBLOADER or OBDUMPER and omit the password options already configured. For example:./obdumper -h 10.0.0.11 -P 2881 -u core_user -t obmysql -D core_db --csv --all -f /data/core_exportReplace the connection parameters and export directory to suit your environment.
Connect to a database over SSL
OBLOADER & OBDUMPER V4.3.1 and later allow you to connect to a database over SSL. This section describes two methods for connecting to a database over SSL.
Method 1: Configure SSL parameters to enable SSL connection
Configure SSL parameters in the session.config.json file. For more information about the file, see Connection configuration.
"useSSL": true,
"disableSslHostnameVerification": true,
"trustStore": "http://xxx.xxx.xxx.xxx:39411/rpcssl/truststore.jks",
"trustStorePassword": "123xxxx",
"//keyStore": "xxxxx",
"//keyStorePassword": ""
Configure the trustStore and trustStorePassword parameters based on the actual situation.
The value of
trustStorecan be an HTTP URL or a local path, for example,"trustStore": "/home/admin/downloads/truststore.jks".The value of
trustStorePasswordis a plaintext password. Pay attention that it is not the database password.
Method 2: Use secure-gen for encryption
You can also use secure-gen to connect to the database to improve security and reduce security risks. The procedure is as follows:
Install OpenSSL and configure environment variables.
Run the following command in the
{ob-loader-dumper}/tools/directory:./secure-gen -iConfigure related password parameters in the CLI and then enter
:wqto save and exit.# Input the sensitive fields below in plain-text respectively. # Note ob-loader-dumper will parse from cli args first, and override any field in this file if there is a conflict. # # This password used for creating JDBC Connection. oceanbase.jdbc.password=******* # This password used for creating JDBC Connection of sys tenant. oceanbase.jdbc.sys.password=****** # Trust store password for creating JDBC Connection with useSSL=true. oceanbase.jdbc.trustStorePassword=****** # Key store password for creating JDBC Connection with useSSL=true (×509). # oceanbase.jdbc.keyStorePassword= # AccessKey for cloud storages like OSS, S3. # cloud.storage.access. key= # SecretKey for cloud storages likeBy default, the encrypted file and key are locally generated by using OpenSSL. Place the encrypted file (
secure.rsa) and key (key.pem) to thesecurity.propertiesfile in theconf/directory.You can also place the encrypted file and key on different HTTP servers. OBLOADER & OBDUMPER automatically loads the encrypted file and key at startup and then decrypts the information.