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.
...
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 |
...
- Download and install WSO2 ESB.
- Open a command prompt and navigate to the
<PRODUCT_HOME>/bin
folder. Enable the Cipher Tool for WSO2 ESB by executing the following command:
Code Block sh ciphertool.sh -Dconfigure
Execute the Cipher Tool using the following command:
Code Block sh ciphertool.sh
- 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 :amqp://admin:admin@clientID/carbon?brokerlist
You will receive the encrypted value as shown below. For example:
Code Block Encrypted value is: gaMpTzAccMScaHllsZLXspm1i4HLI0M/srL5pB8jyknRKQ2zT7NuCvt1+qEkElRLgwlrohz3lkuE0KFuapXrCSs5pxfGMOLn4/k7dNs2SlwbsG8C++/ ZfUuft1Sl6cqvDRM55fQwzCPfybl713HvKu3oDaJ9VKgSbvHlQj6zqzg=
Open the
cipher-text.properties
file, stored in the<ESB_HOME>/repository/conf/security
folder.Add the encrypted password against the secret alias as shown below.
Code Block connectionfactory.QueueConnectionFactory=cpw74SGeBNgAVpryqj5/xshSyW5BDW9d1UW0xMZ DxVeoa6RjyA1JRHutZ4SfzfSgSzy2GQJ/2jQIw70IeT5EQEAR8XLGaqlsE5IlNoe9dhyLiPXEPRGq4k/BgUQD YiBg0nU7wRsR8YXrvf+ak8ulX2yGv0Sf8=
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:
Be sure to shut down the server.
Open a command prompt and go to the
<PRODUCT_HOME>/bin
directory, where we have stored theciphertool.sh
script.Execute the following command:
Code Block ./ciphertool.sh -Dchange
It will prompt for the primary keystore password. Enter the keystore password (which is "wso2carbon" for the default keystore).
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.
The password should now be changed and encrypted.
...