This documentation is for WSO2 Carbon 4.4.0. View documentation for the latest release.
Encrypting Passwords with Cipher Tool - Carbon 4.4.0 - WSO2 Documentation
Due to a known issue do not use JDK1.8.0_151 with WSO2 products. Use JDK 1.8.0_144 until JDK 1.8.0_162-ea is released.
Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 6 Next »

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 Carbon product by implementing a new secret repository, call back handler etc. as explained here.

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 how you can 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:

Note that the Cipher Tool, which is necessary for Secure Vault will be available for download from the WSO2 Git repository soon.

  1. Download the latest released org.wso2.ciphertool_x.x.x.jar from the nexus repository and copy it to the <PRODUCT_HOME>/lib/ directory.
  2. Go to the wso2/cipher-tool git repository (https://github.com/wso2/cipher-tool/tree/master/src/main/resources) and copy the following configuration files:
    • cipher-text.properties
    • cipher-tool.properties
    • ciphertool.bat
    • ciphertool.sh
  3. Copy the above configuration files (cipher-text.properties and cipher-tool.properties) to the <PRODUCT_HOME>/repository/conf/security/ directory and the server startup scripts (ciphertool.bat and ciphertool.sh) to the <PRODUCT_HOME>/bin/ directory.
  4. Now, you must update the cipher-text.properties file and the cipher-tool.properties files with information on the configuration files and the passwords that you want to encrypt. By default, these two files are already configured with the most common passwords that should be encrypted as follows:

     Default cipher-tool.properties
    # Important: This cipher-tool.properties file should be sync with carbon/core/distribution/carbon-home/repository/conf/cipher-tool.properties. This is added here as it goes with wso2 cipher tool.
    # 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 and the value. This value is described as follows.
    # The value goes as, the file name//xpath to the property value to be secured,true if xml elements start with capital letter. Please check existing property values below. 
    Carbon.Security.KeyStore.Password=carbon.xml//Server/Security/KeyStore/Password,true
    Carbon.Security.KeyStore.KeyPassword=carbon.xml//Server/Security/KeyStore/KeyPassword,true
    Carbon.Security.TrustStore.Password=carbon.xml//Server/Security/TrustStore/Password,true
    UserManager.AdminUser.Password=user-mgt.xml//UserManager/Realm/Configuration/AdminUser/Password,true
    Datasources.WSO2_CARBON_DB.Configuration.Password=master-datasources.xml//datasources-configuration/datasources/datasource[name='WSO2_CARBON_DB']/definition[@type='RDBMS']/configuration/password,false
    #Server.Service.Connector.keystorePass=catalina-server.xml//Server/Service/Connector[@keystorePass],false
    #Datasource.WSO2AM_DB.configuration.password=master-datasources.xml//datasources-configuration/datasources/datasource[name='WSO2AM_DB']/definition[@type='RDBMS']/configuration/password,false
    #Datasource.WSO2AM_STATS_DB.configuration.password=master-datasources.xml//datasources-configuration/datasources/datasource[name='WSO2AM_STATS_DB']/definition[@type='RDBMS']/configuration/password,false
    #UserStoreManager.Property.ConnectionPassword=user-mgt.xml//UserManager/Realm/UserStoreManager/Property[@name='ConnectionPassword'],true
    #UserStoreManager.Property.password=user-mgt.xml//UserManager/Realm/UserStoreManager/Property[@name='password'],true
    #AuthManager.Password=api-manager.xml//APIManager/AuthManager/Password,true
    #APIGateway.Password=api-manager.xml//APIManager/APIGateway/Environments/Environment/Password,true
    #APIUsageTracking.BAMPassword=api-manager.xml//APIManager/APIUsageTracking/BAMPassword,true
    #APIUsageTracking.JDBCPassword=api-manager.xml//APIManager/APIUsageTracking/JDBCPassword,true
    #APIKeyManager.Password=api-manager.xml//APIManager/APIKeyManager/Password,true
    #Database.Password=api-manager.xml//APIManager/Database/Password,true
    #Security.UserTrustedRPStore.Password=identity.xml//Server/Security/UserTrustedRPStore/Password
    #Security.UserTrustedRPStore.KeyPassword=identity.xml//Server/Security/UserTrustedRPStore/KeyPassword
    #Identity.System.StorePass=identity.xml//Server/Identity/System/StorePass
    #MultifactorAuthentication.XMPPSettings.XMPPConfig.XMPPPassword=identity.xml//MultifactorAuthentication/XMPPSettings/XMPPConfig/XMPPPassword
    #BPELEPR.Password=securedinvoke.epr//EndpointReference/Metadata/transport/authorization-password,false
    #Axis2.Https.Listener.TrustStore.Password=axis2.xml//axisconfig/transportReceiver[@name='https']/parameter[@name='truststore']/TrustStore/Password,false
    #Axis2.Https.Listener.KeyStore.Password=axis2.xml//axisconfig/transportReceiver[@name='https']/parameter[@name='keystore']/KeyStore/Password,false
    #Axis2.Https.Listener.KeyStore.KeyPassword=axis2.xml//axisconfig/transportReceiver[@name='https']/parameter[@name='keystore']/KeyStore/KeyPassword,false
    #Axis2.Https.Sender.TrustStore.Password=axis2.xml//axisconfig/transportSender[@name='https']/parameter[@name='truststore']/TrustStore/Password,false
    #Axis2.Https.Sender.KeyStore.Password=axis2.xml//axisconfig/transportSender[@name='https']/parameter[@name='keystore']/KeyStore/Password,false
    #Axis2.Https.Sender.KeyStore.KeyPassword=axis2.xml//axisconfig/transportSender[@name='https']/parameter[@name='keystore']/KeyStore/KeyPassword,false
    #Axis2.Mailto.Parameter.Password=axis2.xml//axisconfig/transportSender[@name='mailto']/parameter[@name='mail.smtp.password'],false
    #eventBrokerConfig.eventBroker.deliveryManager.remoteMessageBroker.password=event-broker.xml//eventBrokerConfig/eventBroker/deliveryManager/remoteMessageBroker/password,false
    #Service.LoggingConfig.ArchivedPassword=logging-config.xml//loggingConfig/archivedPassword,false
    #Service.LoggingConfig.Password=logging-config.xml//loggingConfig/password,false
    #Summarizer.LoggingConfig.Password=summarizer-config.xml//loggingConfig/password,false
    #Summarizer.LoggingConfig.BamPassword=summarizer-config.xml//loggingConfig/bamPassword,false
    #Summarizer.LoggingConfig.PublisherPassword=summarizer-config.xml//loggingConfig/publisherPassword,false
     Default cipher-text.properties
    # This is the default file based secret repository, used by Secret Manager of synapse secure vault
    # By default, This file contains the secret alias names Vs the plain text passwords enclosed with '[]' brackets
    # In Production environments, It is recommend to replace those 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]
    UserManager.AdminUser.Password=[admin]
    Datasources.WSO2_CARBON_DB.Configuration.Password=[wso2carbon]
    #Server.Service.Connector.keystorePass=[wso2carbon]
    #datasource.WSO2AM_DB.configuration.password=[wso2carbon]
    #UserStoreManager.Property.ConnectionPassword=[admin]
    #UserStoreManager.Property.password=[admin]
    #AuthManager.Password=[admin]
    #APIGateway.Password=[admin]
    #APIUsageTracking.BAMPassword=[admin]
    #APIUsageTracking.JDBCPassword=[wso2carbon]
    #APIKeyManager.Password=[admin]
    #Database.Password=[wso2carbon]
    #Security.UserTrustedRPStore.Password=[wso2carbon]
    #Security.UserTrustedRPStore.KeyPassword=[wso2carbon]
    #Identity.System.StorePass=[wso2carbon]
    #MultifactorAuthentication.XMPPSettings.XMPPConfig.XMPPPassword=[wso2carbon]
    #BPELEPR.Password=[admin]
    #Axis2.Https.Listener.TrustStore.Password=[wso2carbon]
    #Axis2.Https.Listener.KeyStore.Password=[wso2carbon]
    #Axis2.Https.Listener.KeyStore.KeyPassword=[wso2carbon]
    #Axis2.Https.Sender.TrustStore.Password=[wso2carbon]
    #Axis2.Https.Sender.KeyStore.Password=[wso2carbon]
    #Axis2.Https.Sender.KeyStore.KeyPassword=[wso2carbon]
    #Axis2.Mailto.Parameter.Password=[wso2carbon]
    #eventBrokerConfig.eventBroker.deliveryManager.remoteMessageBroker.password=[admin]
    #Log4j.Appender.LOGEVENT.Password=[admin]
    #Service.LoggingConfig.ArchivedPassword=[admin]
    #Service.LoggingConfig.Password=[admin]
    #Summarizer.LoggingConfig.Password=[admin]
    #Summarizer.LoggingConfig.BamPassword=[admin]
    #Summarizer.LoggingConfig.PublisherPassword=[admin]

    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

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

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

    ./ciphertool.sh -Dconfigure
    The Cipher Tool reads the alias values and their corresponding plain text passwords from the cipher-text.properties file. Note that this tool identifies plain text defined within square brackets as the plain text passwords. If a password is not specified in the cipher-text.properties file for a corresponding 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.
  2. 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".

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

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:

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

  9. You may restart the server.

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.

  • No labels