The instructions on this page explain 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. Read about the Secure Vault implementation in WSO2 products.
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 this link for details 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. You must install and configure the Cipher Tool as explained below:
In any WSO2 product that is based on Carbon 4.4.0 or a later version, the Cipher Tool feature will be installed by default.
If you are a developer who is building a Carbon product, see the topic on enabling Cipher Tool for password encryption for instructions on how to include the Cipher Tool feature in your product build.
- Open the
cipher-text.propertiesfile and the
cipher-tool.propertiesfile from the
- In any WSO2 product that is based on Carbon 4.4.0 or a later version, the following files should be updated with the required information:
cipher-tool.propertiesfile should contain information about the files in which the passwords (that require encryption) are located. Either the relative path or the absolute path of each file starting from
<PRODUCT_HOME>should be given. The last value that follows the file path is set to 'true' or 'false' (which is a boolean value), which indicates whether or note the value to be encrypted is an attribute.
By default, the file that is shipped with your product pack will contain information on the most common passwords that require encryption. For example, see the default file that is created for Carbon Kernel:Default cipher-tool.properties
cipher-text.propertiesfile should contain the secret alias names and the corresponding plain text passwords (enclosed within square brackets). For example, see the default file that is created for Carbon Kernel:Default cipher-text.properties
Step 2: Encrypting the passwords
Open a command prompt and go to the
<PRODUCT_HOME>/bindirectory, where the
ciphertool.shscript is stored.
ciphertool.shscript using the command prompt as shown below:
The Cipher Tool reads the alias values and their corresponding plain text passwords from the
cipher-text.propertiesfile. Shown below is an example of an alias and the corresponding plain text password (in square brackets):
If a password is not specified in the
cipher-text.propertiesfile 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.
When the above command is executed, the following message is prompted: "[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:
cipher-text.propertiesfile and see that the plain text passwords are replaced by a cipher value.
secret-conf.propertiesfile from the
<PRODUCT_HOME>/repository/conf/security/folder and see that the default configurations are changed.
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. The Resolving Passwords topic explains how encrypted passwords are resolved.
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>/bindirectory, where we have stored the
Execute the following command:
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.