How to use SecureVault when WSO2 Carbon servers are started as background processes
SecureVault can be used to encrypt the plain-text passwords specified in various configurations files in WSO2 Carbon products. You can find more information about how to secure plain-text passwords using securevault in this blog written by Asela.
When you use SecureVault to encrypt the passwords as explained there, you are supposed to specify the primary keystore password at the server startup. However, this is not possible when you start the server as a background process.
This post summarizes the complete procedure of securing plain text passwords using secure vault and additional configurations when you start the server as a background process.
Suppose, we need to encrypt the LDAP ConnectionPassword value in CARBON_HOME/repository/conf/user-mgt.xml
When you use SecureVault to encrypt the passwords as explained there, you are supposed to specify the primary keystore password at the server startup. However, this is not possible when you start the server as a background process.
This post summarizes the complete procedure of securing plain text passwords using secure vault and additional configurations when you start the server as a background process.
Suppose, we need to encrypt the LDAP ConnectionPassword value in CARBON_HOME/repository/conf/user-mgt.xml
- Locate cipher-text.properties which can be found at CARBON_HOME/repository/conf/security directory
- Keep a back up of the cipher-text.properties file
- Now, remove all key-value pairs which have there by default in cipher-text.properties file.(In this example, we just need to encrypt ConnectionPassword value)
- Add the following line. Make sure to include your plain_text LDAP connection password in [plain_text_ldap_password]
UserStoreManager.Property.ConnectionPassword=[plain_text_ldap_password] - Locate ciphertool.sh script which can be found at CARBON_HOME/bin directory
- Run ciphertool.sh as follows
ciphertool.sh -Dconfigure
This will prompt "[Please Enter Primary KeyStore Password of Carbon Server : ]" message. Enter "wso2carbon" as the primary keystore password - If the script execution completed successfully, you will see the following message.
"Secret Configurations are written to the property file successfully" - Now, go back and look at the cipher-text.properties file. The plain text LDAP password will be replaced by a cipher value.
- You will also look at CARBON_HOME/repository/conf/user-mgt.xml where we have specified the connection password for LDAP user.
You will notice that it will be modified by the ciphertool script as follows.
<Property name="ConnectionPassword" svns:secretAlias="UserStoreManager.Property.ConnectionPassword">password</Property> - Now, you can start the server.
e.g:- sh wso2server.sh - This will prompt "[Enter KeyStore and Private Key Password :]" at the
server startup because we need to decrypt the encrypted passwords to
connect to LDAP.
You can enter "wso2carbon" and the server will be started successfully.
But you will not be able to provide this password value if you start WSO2 Carbon server as a background process.
i.e:- ./wso2server.sh start
In that case, you can follow a simple set of additional steps as explained below - Have a file named "password-tmp" in CARBON_HOME/ directory. Add "wso2carbon" (the primary keystore password) to this file and save
- Now, start the server as a background process.
./wso2server.sh start - Keystore password will be picked up from password-tmp file. Once the server is started, this fill will automatically be deleted from the file system. Make sure to add this temporary file back whenever you start the sever as a background process.
Comments
FYI, on windows platforms, this file has to be named "password-tmp.txt" otherwise it won't work.