This site contains the documentation that is relevant to older WSO2 product versions and offerings.
For the latest WSO2 documentation, visit https://wso2.com/documentation/.
Encrypting Passwords with Cipher Tool (Carbon 4.3.0)
The instructions on this page explains how plain text passwords in configuration files can be encrypted using the secure vault implementation that is built into WSO2 products. Note that you can customize the default secure vault configurations in the product by implementing a new secret repository, call back handler etc. See the related topics for information about secure vault.
The default keystore that is shipped with your WSO2 product (i.e. wso2carbon.jks) is assumed to be the keystore used for encrypting plain text passwords. See the related topics for information on how to set up and configure new keystores for encrypting plain text passwords.
Follow the steps given below.
Step 1: Setting up Cipher Tool
Passwords are encrypted by executing the Cipher Tool. Therefore, you must first install and configure the Cipher Tool as follows:
- In any WSO2 product based on Carbon 4.4.0, you can install the Cipher Tool feature is installed by default.
- Open the
cipher-text.properties
file and thecipher-tool.properties
file from the<PRODUCT_HOME>/repository/conf/securit
y folder. By default, these two files are already configured with the most common passwords that should be encrypted for your product as shown below. If required, you can edit the information that you want to encrypt.
If there are other passwords from configuration files that you want to encrypt, you can add the details to these files. For example, in WSO2 Storage Server, you will want to configure the "root" password in the
rss-config.xml
file.Add the following to the
cipher-tool.properties
file:#rss-config.xml passwords #RSSConfiguration.DEFAULT.WSO2RSS1.Password=rss-config.xml//RSSConfiguration/Environments/Environment[Name='DEFAULT']/RSSInstances/RSSInstance[Name='WSO2RSS1']/DataSourceConfiguration/Definition/Password,true
Add the following to the
cipher-text.properties
file:#rss-config.xml passwords #RSSConfiguration.DEFAULT.WSO2RSS1.Password=[root]
Step 2: Encrypting the passwords
Open a command prompt and go to the
<PRODUCT_HOME>/bin
directory, where we stored theciphertool.sh
script. Run theciphertool.sh
script using one of the following commands:Use the command given below to simply execute the script. You will be required to provide the keystore password (for authentication) in a later step.
./ciphertool.sh -Dconfigure
Use the command given below if you want to provide the keystore password as you run the script. The default keystore password is "wso2carbon".
./ciphertool.sh -Dconfigure -Dpassword=wso2carbon
The Cipher Tool reads the alias values and their corresponding plain text passwords from the
cipher-text.properties
file. Shown below is an example of an alias and the corresponding plain text password (in square brackets):UserManager.AdminUser.Password=[admin]
If a password is not specified in the
cipher-text.properties
file for an alias, the user needs to provide it through the command-line. Check whether the alias is a known password alias in Carbon configurations. If the tool modifies the configuration element and file, you must replace the configuration element with the alias name. Define a Secret Callback in the configuration file and add proper name spaces for defining the Secure Vault.This step is required only if you did not provide the keystore password in step 1. The following message will be prompted, requesting for the keystore password: "[Please Enter Primary KeyStore Password of Carbon Server : ]". Enter the keystore password (which is "wso2carbon" for the default keystore).
If the script execution completed successfully, you will see the following message: "Secret Configurations are written to the property file successfully".
- Now, to verify the password encryption:
- Open the
cipher-text.properties
file and see that the plain text passwords are replaced by a cipher value. Open the relevant configuration files (e.g.,
rss-config.xml
file) and see that the passwords are encrypted.Open the
secret-conf.properties
file stored in the<PRODUCT_HOME>/repository/conf/security/
folder and see that the default configurations are changed.
- Open the
If you have encrypted passwords as explained above, note that these passwords have to be decrypted again for the server to be usable. That is, the passwords have to be resolved by a system administrator during server startup. See the topic on resolving passwords in the related topics.
Changing encrypted passwords
To change any password which we have encrypted already, follow the below steps:
Be sure to shut down the server.
Open a command prompt and go to the
<PRODUCT_HOME>/bin
directory, where we have stored theciphertool.sh
script.Execute the following command:
./ciphertool.sh -Dchange
It will prompt for the primary keystore password. Enter the keystore password (which is "wso2carbon" for the default keystore).
The alias values of all the passwords that you encrypted will now be shown in a numbered list.
The system will then prompt you to select the alias of the password which you want to change. Enter the list number of the password alias.
The system will then prompt you (twice) to enter the new password. Enter your new password.
The password should now be changed and encrypted.