Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

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 more about the Secure Vault implementation in WSO2 products.

...

  1. The first step is to update the cipher-tool.properties file and the cipher-text.properties file with information of the passwords that you want to encrypt. 

    1. Open the cipher-tool.properties file stored in the <PRODUCT_HOME>/repository/conf/security folder. The file should contain information about the files in which the passwords (that require encryption) are located as shown below:

      Code Block
      <alias>=<file_name>//<xpath>,<true/false>

      For example, if you want to encrypt the admin user password in the user-mgt.xml file, the following should be added to the cipher-tool.properties file:

      Code Block
      UserManager.AdminUser.Password=repository/conf/user-mgt.xml//UserManager/Realm/Configuration/AdminUser/Password,false
      Info

      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' indicating 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. 

    2. Open the cipher-text.properties file stored in the <PRODUCT_HOME>/repository/conf/security folder. This file should contain the secret alias names and the corresponding plain text passwords (enclosed within square brackets) as shown below.

      Code Block
      <alias>=[plain_text_password]

      For example, if you want to encrypt the admin user password in the user-mgt.xml file, the following should be added to the cipher-tool.properties file:

      Code Block
      UserManager.AdminUser.Password=[admin]
  2. Open a command prompt and go to the <PRODUCT_HOME>/bin directory, where the ciphertool.sh script is stored. 

  3. Run the ciphertool.sh script using the command prompt as shown below:

    Code Block
    ./ciphertool.sh -Dconfigure
  4. The following message will be prompted:  "[Please Enter Primary KeyStore Password of Carbon Server : ]". Enter the keystore password (which is "wso2carbon" for the default keystore) and proceed. If the script execution is successful, you will see the following message: "Secret Configurations are written to the property file successfully".

    Note

    The Cipher Tool reads the alias values and their corresponding plain text passwords from the If you are using the cipher tool for the first time, the ./ciphertool.sh -Dconfigure command will first initialize the tool for your product. The tool will then start encrypting the plain text passwords you specified in the cipher-text.properties file file.

    Shown below is an example of an alias and the corresponding plain text password (in square brackets) in the cipher-text.properties file:

    Code Block
    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 namespaces 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"

    .

  5. 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 secret-conf.properties file from the <PRODUCT_HOME>/repository/conf/security/ folder and see that the default configurations are changed.

...

  1. Download and install a WSO2 product.
  2. Open a command prompt and navigate to the <PRODUCT_HOME>/bin folder.
  3. You must first enable the Cipher tool for the product by executing the following command:

    Code Block
    sh ciphertool.sh -Dconfigure 
    Note

    If you are using the cipher tool for the first time, this command will first initialize the tool for your product. The tool will then encrypt any plain text passwords that are specified in the cipher-text.properties file for automatic encryption.

  4. Now, you can start encrypting the admin password manually. Execute the Cipher tool using the following command:

    Code Block
    sh ciphertool.sh
  5. You will be asked to enter the primary key password, which is by default 'wso2carbon'. Enter the password and proceed.
  6. You will now be asked to enter the plain text password that you want to encrypt. Enter the following element as the password and proceed:

    Code Block
    Enter Plain Text Value :admin
    Info

    Note that in certain configuration files, the password that requires encryption may not be specified as a single value as it is in the log4j.properties file. For example, the jndi.properties file used in WSO2 ESB contains the password in the connection URL. In such cases, you need to encrypt the entire connection URL as explained here.

  7. You will receive the encrypted value as shown below. For example:

    Code Block
    Encrypted value is: 
    gaMpTzAccMScaHllsZLXspm1i4HLI0M/srL5pB8jyknRKQ2zT7NuCvt1+qEkElRLgwlrohz3lkuE0KFuapXrCSs5pxfGMOLn4/k7dNs2SlwbsG8C++/
    ZfUuft1Sl6cqvDRM55fQwzCPfybl713HvKu3oDaJ9VKgSbvHlQj6zqzg=
  8. Open the cipher-text.properties file, stored in the <PRODUCT_HOME>/repository/conf/security folder.

  9. Add the encrypted password against the secret alias as shown below.

    Code Block
    log4j.appender.LOGEVENT.password=cpw74SGeBNgAVpryqj5/xshSyW5BDW9d1UW0xMZ
    DxVeoa6RjyA1JRHutZ4SfzfSgSzy2GQJ/2jQIw70IeT5EQEAR8XLGaqlsE5IlNoe9dhyLiPXEPRGq4k/BgUQD
    YiBg0nU7wRsR8YXrvf+ak8ulX2yGv0Sf8=
  10. Now, open the log4j.properties file, stored in the <PRODUCT_HOME>/repository/conf folder and replace the plain text element with the alias of the encrypted value as shown below.

    Code Block
    # LOGEVENT is set to be a LogEventAppender using a PatternLayout to send logs to LOGEVENT 
    ....
    log4j.appender.LOGEVENT.password=secretAlias:log4j.appender.LOGEVENT.password
    ....

...

Changing encrypted passwords

To change any password which we have encrypted already, follow the below steps:

  1. Be sure to shut down the server.

  2. Open a command prompt and go to the <PRODUCT_HOME>/bin directory, where we have stored the ciphertool.sh script.

  3. Execute the following command:

    Code Block
    ./ciphertool.sh -Dchange
  4. It will prompt for the primary keystore password. Enter the keystore password (which is "wso2carbon" for the default keystore).

  5. The alias values of all the passwords that you encrypted will now be shown in a numbered list. 

  6. 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.

  7. The system will then prompt you (twice) to enter the new password. Enter your new password.

  8. The password should now be changed and encrypted.

...