If the directory/file paths specified in this guide do not exist in your WSO2 product, see Directory Structure of WSO2 Products to locate the paths applicable to your product.

Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: A-1285

...

  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. 

    Info

    By default, the cipher-tool.properties and cipher-text.properties files that are shipped with your product will contain information on the most common passwords that require encryption. If a required password is missing in the default files, you can add them manually

    Follow the steps given below.

    1. Open the cipher-tool.properties file stored in the <PRODUCT_HOME>/repository/conf/security folder. This file should contain information about the configuration files in which the passwords (that require encryption) are located. The following format is used:

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

      Important!

      • The <alias> should be the same value that is hard-coded in the relevant Carbon component.
      • The <file_path> specifies the path to the XML file that contains the password. This can be the relative file path, or the absolute file path (starting from <PRODUCT_HOME>).

      • The <xpath> specifies the XPath to the XML element/attribute/tag that should be encrypted. See the examples given below.
      • The flag that follows the XPath should be set to 'false' if you are encrypting the value of an XML element, or the value of an XML attribute's tag. The flag should be 'true' if you are encrypting the tag of an XML  attribute. See the examples given below.

      • When using Secure Vault, as you use the password aliases in the <PRODUCT_HOME>/repository/conf/carbon.xml file, make sure to define these aliases in the following files, which are in the <PRODUCT_HOME>/repository/conf/security directory as follows:

        • Define your password in the cipher-text.properties file.

          Code Block
          Carbon.Security.InternalKeyStore.Password=[your_password]
          Carbon.Security.InternalKeyStore.KeyPassword=[your_password]
        • Define the XPath of your password in the cipher-tool.properties file.

          Code Block
          Carbon.Security.InternalKeyStore.Password=repository/conf/carbon.xml//Server/Security/InternalKeyStore/Password,false
          Carbon.Security.InternalKeyStore.KeyPassword=repository/conf/carbon.xml//Server/Security/InternalKeyStore/KeyPassword,false
      Note
      titleOnly applicable when using WSO2 API Manager Analytics

      When using Secure Vault with WSO2 API Manager Analytics (WSO2 API-M Analytics), make sure to define the password aliases in the following files, which are in the <PRODUCT_HOME>/repository/conf/security directory as follows:

      • Define your password in the cipher-text.properties file.

        Code Block
        DataBridge.Config.keyStorePassword=[your_password]
        Analytics.DASPassword=[your_password]
        Analytics.DASRestApiPassword=[your_password]
        Analytics.StreamProcessorPassword=[admin]
        Analytics.StreamProcessorRestApiPassword=[admin]
      • Define the XPath of your password in the cipher-tool.properties file.

        Code Block
        DataBridge.Config.keyStorePassword=repository/conf/data-bridge/data-bridge-config.xml//dataBridgeConfiguration/keyStorePassword,false
        Analytics.DASPassword=repository/conf/api-manager.xml//APIManager/Analytics/DASPassword,true
        Analytics.DASRestApiPassword=repository/conf/api-manager.xml//APIManager/Analytics/DASRestApiPassword,true
        Analytics.StreamProcessorPassword=repository/conf/api-manager.xml//APIManager/Analytics/StreamProcessorPassword,true
        Analytics.StreamProcessorRestApiPassword=repository/conf/api-manager.xml//APIManager/Analytics/StreamProcessorRestApiPassword,true


      Example 1:
       Consider the admin user's password in the user-mgt.xml file shown below. 

      Code Block
      <UserManager>
          <Realm>
              <Configuration>
      			<AddAdmin>true</AddAdmin>
                  <AdminRole>admin</AdminRole>
                  <AdminUser>
                      <UserName>admin</UserName>
                      <Password>admin</Password>
                  </AdminUser>
      			........
      		</Configuation>
      		........
      	</Realm>
      </UserManager>

      To encrypt this password, the cipher-tool.properties file should contain the details shown below. Note that this password is a value given to an XML element (which is 'Password'). Therefore, the XPath ends with the element name, and the flag that follows the XPath is set to 'false'.

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

      Example 2: Consider the password that is used to connect to an LDAP user store (configured in the user-mgt.xml file) shown below.

      Code Block
      <Property name="ConnectionPassword">admin</Property>

      To encrypt this password, the cipher-tool.properties file should be updated as shown below. Note that there are two possible alias values you can use for this attribute. In this example, the 'Property' element of the XML file uses the 'name' attribute with the "ConnectionPassword" tag. The password we are encrypting is the value of this "ConnectionPassword" tag. This is denoted in the XPath as 'Property[@name='ConnectionPassword']', and the flag that follows the XPath is set to 'false'.

      • Using the UserStoreManager.Property.ConnectionPassword alias:

        Code Block
        UserStoreManager.Property.ConnectionPassword=repository/conf/user-mgt.xml//UserManager/Realm/UserStoreManager/Property[@name='ConnectionPassword'],false
      • Using the UserManager.Configuration.Property.ConnectionPassword alias:

        Code Block
        UserManager.Configuration.Property.ConnectionPassword=repository/conf/user-mgt.xml//UserManager/Realm/UserStoreManager/Property[@name='ConnectionPassword'],false
      Note

      If you are trying the above example, be sure that only the relevant user store manager is enabled in the user-mgt.xml file.

      Example 3: Consider the keystore password specified in the catalina-server.xml file shown below. 

      Code Block
      <Connector protocol="org.apache.coyote.http11.Http11NioProtocol"  
       ... 
       keystorePass="wso2carbon" 
      ... >

      To encrypt this password, the cipher-tool.properties file should contain the details shown below. In this example, 'Connector' is the XML element, and 'keystorePass' is an attribute of that element. The password value that we are encrypting is the tag of the XML attribute. This is denoted in the XPath as 'Connector[@keystorePass]', and the flag that follows the XPath is set to ‘true’.

      Code Block
      Server.Service.Connector.keystorePass=repository/conf/tomcat/catalina-server.xml//Server/Service/Connector[@keystorePass],true
      Expand
      titleExpand to view a list of the aliases available in the cipher-tool.properties file.

      The following is a list of the aliases available in the <PRODUCT_HOME>/repository/conf/security/cipher-tool.properties file. Note that aliases can be any string that you prefer.

      Code Block
      UserStoreManager.Property.ConnectionPassword=repository/conf/user-mgt.xml//UserManager/Realm/UserStoreManager/Property[@name='ConnectionPassword'],true
      UserStoreManager.Property.password=repository/conf/user-mgt.xml//UserManager/Realm/UserStoreManager/Property[@name='password'],true
      Security.UserTrustedRPStore.Password=repository/conf/identity.xml//Server/Security/UserTrustedRPStore/Password,false
      Security.UserTrustedRPStore.KeyPassword=repository/conf/identity.xml//Server/Security/UserTrustedRPStore/KeyPassword,false
      Identity.System.StorePass=repository/conf/identity.xml//Server/Identity/System/StorePass,false
      MultifactorAuthentication.XMPPSettings.XMPPConfig.XMPPPassword=repository/conf/identity.xml//MultifactorAuthentication/XMPPSettings/XMPPConfig/XMPPPassword,false
      Axis2.Https.Listener.TrustStore.Password=repository/conf/axis2/axis2.xml//axisconfig/transportReceiver[@name='https']/parameter[@name='truststore']/TrustStore/Password,false
      Axis2.Https.Listener.KeyStore.Password=repository/conf/axis2/axis2.xml//axisconfig/transportReceiver[@name='https']/parameter[@name='keystore']/KeyStore/Password,false
      Axis2.Https.Listener.KeyStore.KeyPassword=repository/conf/axis2/axis2.xml//axisconfig/transportReceiver[@name='https']/parameter[@name='keystore']/KeyStore/KeyPassword,false
      Axis2.Https.Sender.TrustStore.Password=repository/conf/axis2/axis2.xml//axisconfig/transportSender[@name='https']/parameter[@name='truststore']/TrustStore/Password,false
      Axis2.Https.Sender.KeyStore.Password=repository/conf/axis2/axis2.xml//axisconfig/transportSender[@name='https']/parameter[@name='keystore']/KeyStore/Password,false
      Axis2.Https.Sender.KeyStore.KeyPassword=repository/conf/axis2/axis2.xml//axisconfig/transportSender[@name='https']/parameter[@name='keystore']/KeyStore/KeyPassword,false
      SslProfiles.KeyStore.Password=/repository/resources/security/sslprofiles.xml//parameter/profile/KeyStore/Password,false
      SslProfiles.KeyStore.KeyPassword=/repository/resources/security/sslprofiles.xml//parameter/profile/KeyStore/KeyPassword,false
      SslProfiles.TrustStore.Password=/repository/resources/security/sslprofiles.xml//parameter/profile/TrustStore/Password,false
      
      Expand
      titleClick here to see the API Manager specific configurations

      The following are the aliases specific for WSO2 API Manager.

      Code Block
      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
      Carbon.Security.InternalKeyStore.Password=repository/conf/carbon.xml//Server/Security/InternalKeyStore/Password,false
      Carbon.Security.InternalKeyStore.KeyPassword=repository/conf/carbon.xml//Server/Security/InternalKeyStore/KeyPassword,false
      UserStoreManager.Property.ConnectionPassword=repository/conf/user-mgt.xml//UserManager/Realm/UserStoreManager/Property[@name='ConnectionPassword'],true
      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
      AuthManager.Password=repository/conf/api-manager.xml//APIManager/AuthManager/Password,false
      APIGateway.Password=repository/conf/api-manager.xml//APIManager/APIGateway/Environments/Environment/Password,false
      APIKeyValidator.Password=repository/conf/api-manager.xml//APIManager/APIKeyValidator/Password,false
      APIStore.Password=repository/conf/api-manager.xml//APIManager/APIStore/Password,false
      WorkflowConfigurations.Password=repository/conf/api-manager.xml//APIManager/WorkflowConfigurations/ServerPassword,true
      WorkflowConfigurations.DCREndPointPassword=repository/conf/api-manager.xml//APIManager/WorkflowConfigurations/DCREndPointPassword,true
      Datasource.WSO2AM_DB.configuration.password=repository/conf/datasources/master-datasources.xml//datasources-configuration/datasources/datasource[name='WSO2AM_DB']/definition[@type='RDBMS']/configuration/password,false
      Datasources.WSO2UM_DB.Configuration.Password=repository/conf/datasources/master-datasources.xml//datasources-configuration/datasources/datasource[name='WSO2UM_DB']/definition[@type='RDBMS']/configuration/password,false
      Datasources.WSO2REG_DB.Configuration.Password=repository/conf/datasources/master-datasources.xml//datasources-configuration/datasources/datasource[name='WSO2REG_DB']/definition[@type='RDBMS']/configuration/password,false
      Datasources.WSO2_MB_STORE_DB.Configuration.Password=repository/conf/datasources/master-datasources.xml//datasources-configuration/datasources/datasource[name='WSO2_MB_STORE_DB']/definition[@type='RDBMS']/configuration/password,false
      Datasources.WSO2AM_STATS_DB.Configuration.Password=repository/conf/datasources/master-datasources.xml//datasources-configuration/datasources/datasource[name='WSO2AM_STATS_DB']/definition[@type='RDBMS']/configuration/password,false
      Datasources.Metrics.WSO2_METRICS_DB.Configuration.Password=repository/conf/datasources/metrics-datasources.xml//datasources-configuration/datasources/datasource[name=WSO2_METRICS_DB]/definition[@type='RDBMS']/configuration/password,false
      ThrottlingConfigurations.TrafficManager.Password=repository/conf/api-manager.xml//APIManager/ThrottlingConfigurations/TrafficManager/Password,false ThrottlingConfigurations.PolicyDeployer.Password=repository/conf/api-manager.xml//APIManager/ThrottlingConfigurations/PolicyDeployer/Password,false
      TopicConnectionFactory.Url=repository/conf/api-manager.xml//APIManager/ThrottlingConfigurations/JMSConnectionDetails/JMSConnectionParameters/connectionfactory.TopicConnectionFactory,false
      transports.amqp.sslConnection.keyStore.password=repository/conf/broker.xml//broker/transports/amqp/sslConnection/keyStore/password,false
      transports.amqp.sslConnection.trustStore.password=repository/conf/broker.xml//broker/transports/amqp/sslConnection/trustStore/password,false
      transports.mqtt.sslConnection.keyStore.password=repository/conf/broker.xml//broker/transports/mqtt/sslConnection/keyStore/password,false
      transports.mqtt.sslConnection.trustStore.password=repository/conf/broker.xml//broker/transports/mqtt/sslConnection/trustStore/password,false
      Axis2.Https.Listener.TrustStore.Password=repository/conf/axis2/axis2.xml//axisconfig/transportReceiver[@name='https']/parameter[@name='truststore']/TrustStore/Password,false
      Axis2.Https.Listener.KeyStore.Password=repository/conf/axis2/axis2.xml//axisconfig/transportReceiver[@name='https']/parameter[@name='keystore']/KeyStore/Password,false
      Axis2.Https.Listener.KeyStore.KeyPassword=repository/conf/axis2/axis2.xml//axisconfig/transportReceiver[@name='https']/parameter[@name='keystore']/KeyStore/KeyPassword,false
      Axis2.Https.Sender.TrustStore.Password=repository/conf/axis2/axis2.xml//axisconfig/transportSender[@name='https']/parameter[@name='truststore']/TrustStore/Password,false
      Axis2.Https.Sender.KeyStore.Password=repository/conf/axis2/axis2.xml//axisconfig/transportSender[@name='https']/parameter[@name='keystore']/KeyStore/Password,false
      Axis2.Https.Sender.KeyStore.KeyPassword=repository/conf/axis2/axis2.xml//axisconfig/transportSender[@name='https']/parameter[@name='keystore']/KeyStore/KeyPassword,false
      Axis2.PasstruHttps.Receiver.TrustStore.Password=repository/conf/axis2/axis2.xml//axisconfig/transportReceiver[@name='passthru-https']/parameter[@name='truststore']/TrustStore/Password,false
      Axis2.PasstruHttps.Receiver.KeyStore.Password=repository/conf/axis2/axis2.xml//axisconfig/transportReceiver[@name='passthru-https']/parameter[@name='keystore']/KeyStore/Password,false
      Axis2.PasstruHttps.Receiver.KeyStore.KeyPassword=repository/conf/axis2/axis2.xml//axisconfig/transportReceiver[@name='passthru-https']/parameter[@name='keystore']/KeyStore/KeyPassword,false
      Axis2.PasstruHttps.Sender.TrustStore.Password=repository/conf/axis2/axis2.xml//axisconfig/transportSender[@name='passthru-https']/parameter[@name='truststore']/TrustStore/Password,false
      Axis2.PasstruHttps.Sender.KeyStore.Password=repository/conf/axis2/axis2.xml//axisconfig/transportSender[@name='passthru-https']/parameter[@name='keystore']/KeyStore/Password,false
      Axis2.PasstruHttps.Sender.KeyStore.KeyPassword=repository/conf/axis2/axis2.xml//axisconfig/transportSender[@name='passthru-https']/parameter[@name='keystore']/KeyStore/KeyPassword,false
      Axis2.Mailto.Sender.Password=repository/conf/axis2/axis2.xml//axisconfig/transportSender[@name='mailto']/parameter[@name='mail.smtp.password'],false
      Axis2.WSS.Sender.TrustStore.Password=repository/conf/axis2/axis2.xml//axisconfig/transportSender[@name='wss']/parameter[@name='ws.trust.store']/ws.trust.store.Password,false
      MultifactorAuthentication.XMPPSettings.XMPPConfig.XMPPPassword=repository/conf/identity/identity.xml//MultifactorAuthentication/XMPPSettings/XMPPConfig/XMPPPassword,false
      EntitlementSettings.ThirftBasedEntitlementConfig.KeyStore.Password=repository/conf/identity/identity.xml//EntitlementSettings/ThirftBasedEntitlementConfig/KeyStore/Password,false
      AdaptiveAuth.EventPublisher.BasicAuthentication.Password=repository/conf/identity/identity.xml//AdaptiveAuth/EventPublisher/BasicAuthentication/Password,false



    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 plaintext passwords (enclosed within square brackets) as shown below.

      Code Block
      <alias>=[plain_text_password]

      Shown below are the records in the cipher-text.properties file for the three examples discussed above.

      Code Block
      //Example 1: Encrypting the admin user's password in the user-mgt.xml file.
      UserManager.AdminUser.Password=[admin]
      //Example 2: Encrypting the LDAP connection password in the user-mgt.xml file. Use one of the following:
      UserStoreManager.Property.ConnectionPassword=[admin]
      # UserManager.Configuration.Property.ConnectionPassword=[admin]
      //Example 3: Encrypting the keystore password in the catalina-server.xml file.
      Server.Service.Connector.keystorePass=[wso2carbon]
      Expand
      titleExpand to view a list of the aliases available in the cipher-text.properties file.

      The following is a list of the aliases available in the <PRODUCT_HOME>/repository/conf/security/cipher-text.properties file. Note that aliases can be any string that you prefer.

      Code Block
      UserStoreManager.Property.ConnectionPassword=[admin]
      UserStoreManager.Property.password=[admin]
      Security.UserTrustedRPStore.Password=[wso2carbon]
      Security.UserTrustedRPStore.KeyPassword=[wso2carbon]
      Identity.System.StorePass=[wso2carbon]
      MultifactorAuthentication.XMPPSettings.XMPPConfig.XMPPPassword=[wso2carbon]
      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]
      SslProfiles.KeyStore.Password=[wso2carbon]
      SslProfiles.KeyStore.KeyPassword=[wso2carbon]
      SslProfiles.TrustStore.Password=[wso2carbon]
      Expand
      titleClick here to see the API Manager specific configurations

      The following are the aliases specific for WSO2 API Manager.

      Code Block
      Carbon.Security.KeyStore.Password=[wso2carbon]
      Carbon.Security.KeyStore.KeyPassword=[wso2carbon]
      Carbon.Security.TrustStore.Password=[wso2carbon]
      Carbon.Security.InternalKeyStore.Password=[wso2carbon]
      Carbon.Security.InternalKeyStore.KeyPassword=[wso2carbon]
      UserStoreManager.Property.ConnectionPassword=[admin]
      UserManager.AdminUser.Password=[admin]
      Datasources.WSO2_CARBON_DB.Configuration.Password=[wso2carbon]
      Server.Service.Connector.keystorePass=[wso2carbon]
      AuthManager.Password=[admin]
      APIGateway.Password=[admin]
      APIKeyValidator.Password=[admin]
      APIStore.Password=[admin]
      WorkflowConfigurations.Password=[admin]
      WorkflowConfigurations.DCREndPointPassword=[admin]
      Datasource.WSO2AM_DB.configuration.password=[wso2carbon]
      Datasources.WSO2UM_DB.Configuration.Password=[wso2carbon]
      Datasources.WSO2REG_DB.Configuration.Password=[wso2carbon]
      Datasources.WSO2_MB_STORE_DB.Configuration.Password=[wso2carbon]
      Datasources.WSO2AM_STATS_DB.Configuration.Password=[wso2carbon]
      Datasources.Metrics.WSO2_METRICS_DB.Configuration.Password=[wso2carbon]
      TrafficManager.Password=[admin]
      PolicyDeployer.Password=[admin]
      TopicConnectionFactory.Url=[amqp://${admin.username}:${admin.password}@clientid/carbon?brokerlist='tcp://${carbon.local.ip}:${jms.port}'] `
      transports.amqp.sslConnection.keyStore.password=[wso2carbon]
      transports.amqp.sslConnection.trustStore.password=[wso2carbon]
      transports.mqtt.sslConnection.keyStore.password=[wso2carbon]
      transports.mqtt.sslConnection.trustStore.password=[wso2carbon]
      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.PasstruHttps.Receiver.TrustStore.Password=[wso2carbon]
      Axis2.PasstruHttps.Receiver.KeyStore.Password=[wso2carbon]
      Axis2.PasstruHttps.Receiver.KeyStore.KeyPassword=[wso2carbon]
      Axis2.PasstruHttps.Sender.TrustStore.Password=[wso2carbon]
      Axis2.PasstruHttps.Sender.KeyStore.Password=[wso2carbon]
      Axis2.PasstruHttps.Sender.KeyStore.KeyPassword=[wso2carbon]
      Axis2.Mailto.Sender.Password=[wso2carbon]
      Axis2.WSS.Sender.TrustStore.Password=[wso2carbon]
      MultifactorAuthentication.XMPPSettings.XMPPConfig.XMPPPassword=[wso2carbon]
      EntitlementSettings.ThirftBasedEntitlementConfig.KeyStore.Password=[wso2carbon]
      AdaptiveAuth.EventPublisher.BasicAuthentication.Password=[wso2carbon]



    Note

    If your password contains a backslash character (\) you need to use an alias with the escape characters. For example, if your password is admin\} the value should be given as shown in the example below.

    Code Block
    UserStoreManager.Property.ConnectionPassword=[admin\\}]
  2. Open a command prompt and go to the <PRODUCT_HOME>/bin directory, where the cipher tool scripts (for Windows and Linux) are stored. 

  3. Execute the cipher tool script from the command prompt using the command relevant to your OS: 

    • On Windows: ./ciphertool.bat -Dconfigure

    • On Linux: ./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

    If you are using the cipher tool for the first time, the-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.

    Shown below is an example of an alias and the corresponding plaintext 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 namespaces for defining the Secure Vault.

  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.

...