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.

...

...

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. Read more about creating and configuring new keystores.

Follow the steps given below.

...

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. You can use this tool to easily encrypt passwords or other elements in configuration files.

Note

Note the following before you begin:

  • 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 as a feature in your product build.
  • The default keystore that is shipped with your WSO2 product (i.e. wso2carbon.

...

  • jks) is used for password encryption by default. See this link for details on how to set up and configure new keystores for encrypting plain text passwords.

Follow the topics given below for instructions.

Table of Contents
maxLevel3
minLevel3

Encrypting passwords using the automated process

This automated process can only be used for passwords that can be given as an xpath. If you cannot give an xpath for the password that you want to encrypt, you must use the manual encryption process explained in the next section.

Follow the steps given below to have passwords encrypted using the automated process:

  1. The first step is to update the cipher-tool.properties file and the cipher-text.properties file

    and

    with information of the passwords that you want to encrypt. 

    1. Open the cipher-tool.properties file

    from
    1. stored in the <PRODUCT_HOME>/repository/conf/

    security folder. 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: The cipher-tool.properties file
    1. 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'

    (which is a boolean value), which indicates
    1. 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.

    For example, see the default file that is created for Carbon Kernel:
    Expand
    titleDefault cipher-tool.properties
    Code Block
    # Important: This properties file contains all the aliases to be used in carbon components. If any property need to be secured, you need to add alias name, file name and the xpath as follows:.
    # The value goes as, the <file_name>//<xpath>,<true/false>
    # where <file_name> - is the file (along with the file path) to be secured,
    #       <xpath> - is the xpath to the property value to be secured
    #       <true / false> - This is true if the last parameter in the xpath is parameter (starts with [ and ends with ]) and you want its value to be replaced with "password"
    
    Carbon.Security.KeyStore.Password=repository/conf/carbon.xml//Server/Security/KeyStore/Password,false
    Carbon.Security.KeyStore.KeyPassword=repository/conf/carbon.xml//Server/Security/KeyStore/KeyPassword,false
    Carbon.Security.TrustStore.Password=repository/conf/carbon.xml//Server/Security/TrustStore/Password,false
    UserManager.AdminUser.Password=repository/conf/user-mgt.xml//UserManager/Realm/Configuration/AdminUser/Password,false
    Datasources.WSO2_CARBON_DB.Configuration.Password=repository/conf/datasources/master-datasources.xml//datasources-configuration/datasources/datasource[name='WSO2_CARBON_DB']/definition[@type='RDBMS']/configuration/password,false
    Server.Service.Connector.keystorePass=repository/conf/tomcat/catalina-server.xml//Server/Service/Connector[@keystorePass],true
    The cipher-text.properties file
    1.  

    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)

    . For example, see the default file that is created for Carbon Kernel: Expand
    titleDefault cipher-text.properties
    Code Block# By default, This file contains the secret alias names and the plain text passwords enclosed with '[]' brackets # In Production environments, It is recommend to replace these plain text password by the encrypted values. CipherTool can be used for it. Carbon.Security.KeyStore.Password=[wso2carbon] Carbon.Security.KeyStore.KeyPassword=[wso2carbon] Carbon.Security.TrustStore.Password=[wso2carbon]
    1. 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
    ] Datasources.WSO2_CARBON_DB.Configuration.Password=[wso2carbon
    1. ]
    Server.Service.Connector.keystorePass=[wso2carbon]

...

...

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

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

    Code Block
    ./ciphertool.sh -Dconfigure
    Note

    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):

    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 for defining the Secure Vault.

  3. 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".

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

...

Encrypting passwords manually

This manual process of encrypting elements in configuration files is particularly important if you want to encrypt elements that cannot use an xpath to specify the location. In the automated process explained before, we updated the cipher-tool.properties file using an xpath. However, we cannot use xpath notations for certain configuration files. For example, consider the sample jndi.properties file shown below. This file is used in WSO2 Enterprise Service Bus (WSO2 ESB) for the purpose of connecting to a message broker. You can read more about this functionality from here.

As shown below, this file contains a password value (admin), which is the password used when WSO2 ESB connects to a message broker. To encrypt this password, you must manually encrypt the entire Queue Connection Factory value (amqp://admin:admin@clientID/carbon?brokerlist).

Code Block
# register some connection factories
# connectionfactory.[jndiname] = [ConnectionURL]
connectionfactory.QueueConnectionFactory = amqp://admin:admin@clientID/carbon?brokerlist

# register some queues in JNDI using the form
# queue.[jndiName] = [physicalName]
queue.MyQueue = example.MyQueue

# register some topics in JNDI using the form
# topic.[jndiName] = [physicalName]
topic.MyTopic = example.MyTopic

Follow the steps given below.

  1. Download and install WSO2 ESB.
  2. Open a command prompt and navigate to the <PRODUCT_HOME>/bin folder.
  3. Execute the Cipher Tool using the following command:

    Code Block
    sh ciphertool.sh
  4. You will be asked to enter the primary key password, which is by default 'wso2carbon'. Enter the password and proceed.
  5. 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 :amqp://admin:admin@clientID/carbon?brokerlist
  6. You will receive the encrypted value as shown below. For example:

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

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

    Code Block
    connectionfactory.QueueConnectionFactory=cpw74SGeBNgAVpryqj5/xshSyW5BDW9d1UW0xMZ
    DxVeoa6RjyA1JRHutZ4SfzfSgSzy2GQJ/2jQIw70IeT5EQEAR8XLGaqlsE5IlNoe9dhyLiPXEPRGq4k/BgUQD
    YiBg0nU7wRsR8YXrvf+ak8ulX2yGv0Sf8=
  9. Now, open the jndi.properties file, stored in the <ESB_HOME>/repository/conf folder and replace the plain text element with the alias of the encrypted value as shown below.

    Code Block
    # register some connection factories
    # connectionfactory.[jndiname] = [ConnectionURL]
    connectionfactory.QueueConnectionFactory=secretAlias:connectionfactory.QueueConnectionFactory
    
    # register some queues in JNDI using the form
    # queue.[jndiName] = [physicalName]
    queue.MyQueue = example.MyQueue
    
    # register some topics in JNDI using the form
    # topic.[jndiName] = [physicalName]
    topic.MyTopic = example.MyTopic

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

Info

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.