Encrypting passwords manually
This manual process of encrypting elements in configuration files is particularly important 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 use an xpath to specify the location . In in a configuration file, you must use manual encryption. It is not possible to use 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 (
# register some connection factories # connectionfactory.[jndiname] = [ConnectionURL] connectionfactory.QueueConnectionFactory = amqp://admin:[email protected]/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.
encryption process if an xpath is not specified for the element.
log4j.propertiesfile given below, which does not use xpath notations. As shown below, the password of the
LOGEVENTappender is set to
# 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 navigate to the
Enable You must first enable the Cipher Tool tool for the product by executing the following command:
sh ciphertool.sh -Dconfigure
Now, you can start encrypting the admin password manually. Execute the Cipher Tool tool using the following command:
- 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:
Enter Plain Text Value :amqp://admin:[email protected]/carbon?brokerlist='tcp://localhost:5673'admin
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 as shown below. For example:
Encrypted value is: gaMpTzAccMScaHllsZLXspm1i4HLI0M/srL5pB8jyknRKQ2zT7NuCvt1+qEkElRLgwlrohz3lkuE0KFuapXrCSs5pxfGMOLn4/k7dNs2SlwbsG8C++/ ZfUuft1Sl6cqvDRM55fQwzCPfybl713HvKu3oDaJ9VKgSbvHlQj6zqzg=
cipher-text.propertiesfile, stored in the
Add the encrypted password against the secret alias as shown below.
connectionfactory.QueueConnectionFactorylog4j.appender.LOGEVENT.password=cpw74SGeBNgAVpryqj5/xshSyW5BDW9d1UW0xMZ DxVeoa6RjyA1JRHutZ4SfzfSgSzy2GQJ/2jQIw70IeT5EQEAR8XLGaqlsE5IlNoe9dhyLiPXEPRGq4k/BgUQD YiBg0nU7wRsR8YXrvf+ak8ulX2yGv0Sf8=
Now, open the jndithe
log4j.propertiesfile, stored in the
<ESB<PRODUCT_HOME>/repository/conffolder and replace the plain text element with the alias of the encrypted value as shown below.
# LOGEVENT is set to be a LogEventAppender using a PatternLayout to send logs to LOGEVENT .... log4j.appender.LOGEVENT.password=secretAlias:log4j.appender.LOGEVENT.password ....
# register some connection factories # connectionfactory.[jndiname] = [ConnectionURL] connectionfactory.QueueConnectionFactory
= amqp://admin:[email protected]/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
Changing encrypted passwords