Page History
The instructions on this page explains 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 Carbon product by implementing a new secret repository, call back handler etc. as explained here.
...
. Read more about the Secure Vault implementation in WSO2 products.
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 | ||
---|---|---|
| ||
|
Follow the steps topics given below for instructions.
Table of Contents | ||||
---|---|---|---|---|
|
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:
...
- cipher-text.properties
- cipher-tool.properties
- ciphertool.bat
- ciphertool.sh
...
Before you begin
If you are using Windows, you need to have Ant (http://ant.apache.org/) installed before using the Cipher Tool.
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:
The first step is to update the
cipher-tool.properties
file and thecipher-text.properties
file with information of the passwords that you want to encrypt.Info By default, the
cipher-tool.properties
andcipher-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.
Open the
cipher-tool.properties
file stored in the<PRODUCT_HOME>/repository/conf/security
ciphertool.bat
andciphertool.sh
) to the<PRODUCT_HOME>/bin/
directory.Now, you must update the
cipher-text.properties
file and thecipher-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:Expand title 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=Code Block 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 hardcoded 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.
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,
- The
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'],
Expand title Default cipher-text.properties Code Block # 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:Code Block #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:Code Block #rss-config.xml passwords #RSSConfiguration.DEFAULT.WSO2RSS1.Password=[root]
...
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
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]
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\\}]
Open a command prompt and go to the
<PRODUCT_HOME>/bin
directory, where the cipher tool scripts (for Windows and Linux) are stored.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
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 plaintext passwords you specified in thecipher-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.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 can be used for encrypting any password in a configuration file. However, if you want to encrypt any elements that cannot use an xpath to specify the location in a configuration file, you must use manual encryption. It is not possible to use the automated encryption process if an xpath is not specified for the element.
Anchor | ||||
---|---|---|---|---|
|
log4j.properties
file given below, which does not use xpath notations. As shown below, the password of the LOGEVENT
appender is set to admin
:Code Block |
---|
# LOGEVENT is set to be a LogEventAppender using a PatternLayout to send logs to LOGEVENT
log4j.appender.LOGEVENT=org.wso2.carbon.logging.service.appender.LogEventAppender
log4j.appender.LOGEVENT.url=tcp://localhost:7611
log4j.appender.LOGEVENT.layout=org.wso2.carbon.utils.logging.TenantAwarePatternLayout
log4j.appender.LOGEVENT.columnList=%T,%S,%A,%d,%c,%p,%m,%I,%Stacktrace
log4j.appender.LOGEVENT.userName=admin
log4j.appender.LOGEVENT.password=admin
log4j.appender.LOGEVENT.processingLimit=1000
log4j.appender.LOGEVENT.maxTolerableConsecutiveFailure=20 |
Since we cannot use the automated process to encrypt the admin
password shown above, follow the steps given below to encrypt it manually.
- Download and install a WSO2 product.
Open a command prompt and go to the
<PRODUCT_HOME>/bin
directory, where the cipher tool scripts (for Windows and Linux) are stored.You must first enable the Cipher tool for the product by executing the
-
Dconfigure command with the cipher tool script as shown below.On Linux:
./ciphertool.sh -Dconfigure
On Windows:
./ciphertool.bat -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. See the automated encryption process for more information.Now, you can start encrypting the admin password manually. Execute the Cipher tool using the relevant command for your OS:
On Linux:
./ciphertool.sh
On Windows:
./ciphertool.bat
- You will be asked to enter the primary key password, which is by default 'wso2carbon'. Enter the password and proceed.
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.
You will receive the encrypted value. For example:
Code Block Encrypted value is: gaMpTzAccMScaHllsZLXspm1i4HLI0M/srL5pB8jyknRKQ2zT7NuCvt1+qEkElRLgwlrohz3lkuE0KFuapXrCSs5pxfGMOLn4/k7dNs2SlwbsG8C++/ ZfUuft1Sl6cqvDRM55fQwzCPfybl713HvKu3oDaJ9VKgSbvHlQj6zqzg=
Open the
cipher-text.properties
file, stored in the<PRODUCT_HOME>/repository/conf/security
folder.Add the encrypted password against the secret alias as shown below.
Code Block log4j.appender.LOGEVENT.password=cpw74SGeBNgAVpryqj5/xshSyW5BDW9d1UW0xMZ DxVeoa6RjyA1JRHutZ4SfzfSgSzy2GQJ/2jQIw70IeT5EQEAR8XLGaqlsE5IlNoe9dhyLiPXEPRGq4k/BgUQD YiBg0nU7wRsR8YXrvf+ak8ulX2yGv0Sf8=
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 ....
Anchor | ||||
---|---|---|---|---|
|
Code Block |
---|
# register some connection factories
# connectionfactory.[jndiname] = [ConnectionURL]
connectionfactory.QueueConnectionFactory = amqp://admin:[email protected]/carbon?brokerlist='tcp://localhost:5673'
# 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:
Be sure to shut down the server.
Open a command prompt and go to the
<PRODUCT_HOME>/bin
directory, where we stored theciphertool.sh
script.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. Note that this tool identifies plain text defined within square brackets as the plain text passwords. If a password is not specified in thecipher-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.When the above command is executed, the following message is prompted: "[Please Enter Primary KeyStore Password of Carbon Server : ]". Enter the cipher tool scripts (for Windows and Linux) are stored.
Execute the following command for your OS:
On Linux:
./ciphertool.sh -Dchange
On Windows:
./ciphertool.bat -Dchange
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.It will prompt for the primary keystore password. 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:- 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 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.
secret-conf.properties
file stored in the <PRODUCT_HOME>/repository/conf/security/
folder and see that the default configurations are changed.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. |