WSO2 Carbon is shipped with a Secure Vault implementation, which is a modified version of synapse Secure Vault. This allows you to store encrypted passwords that are mapped to aliases. That is, you can use the aliases instead of the actual passwords in your configuration files for better security. For example, some configurations require the admin username and password. If the admin user password is "admin", you could use the alias The Cipher Tool is used in WSO2 products to create encrypted values for passwords. Some of the important elements in the secure vault implementation, which are used in Carbon products for encrypting plain text passwords are as follows: You can implement your own Secure Vault configurations by changing the following according to your choice: Let's see how we can write a new Secret Callback Handler class to secure the user management and registry database connection password. In this sample, you do not need to configure a Secret Repository or keystore (cipher-text.properties) as you are not going to store the secret or encrypted values. Write a Secret Callback class. You need to implement the SecretCallbackHandler interface or extend the AbstractSecretCallbackHandler abstract class. For example, We can set multiple password-based as follows: Configure the Also, replace the secret callback handler class name in UserManager.AdminUser.Password
in your configuration file. You would then map that alias to the actual password "admin". At runtime, the product will look up this alias in the secure vault and then decrypt and use its password.cipher-text.properties
file, located in the <PRODUCT_HOME>/repository/conf/security
folder is the default file based secret repository used by the Secret Manager in your Carbon product. Note that, currently, Secure Vault only implements file based secret repositories. The Secret Repository stores aliases vs. their actual secrets in encrypted format (encrypted via a key in keystore). Any secret repositories can be written by implementing the SecretRepository and SecretRepositoryProvider classes. See the topic on creating custom secure vault configurations.cipher-text.properties
file. The keystore is required to create the decryption crypto, which can be used to resolve encrypted secret values. The keystore and Secret Repository are configurable through the secret-conf.properties
file, which is created in the <PRODUCT_HOME>/repository/conf/security
folder when you execute the Cipher Tool.SecretManagerSecretCallbackHandler
, which is combined with Secret Manager to resolve the secret. Any callback can be written by implementing the SecretCallbackHandler
class. See the topic on creating custom secure vault configurations.Create custom Secure Vault configuration
public class HardCodedSecretCallbackHandler extends AbstractSecretCallbackHandler {
protected void handleSingleSecretCallback(SingleSecretCallback singleSecretCallback) {
singleSecretCallback.setSecret("password");
}
}
public class HardCodedSecretCallbackHandler extends AbstractSecretCallbackHandler {
protected void handleSingleSecretCallback(SingleSecretCallback singleSecretCallback) {
if("foo".equals(singleSecretCallback.getId())){
singleSecretCallback.setSecret("foo_password");
} else if("bar".equals(singleSecretCallback.getId())){
singleSecretCallback.setSecret("bar_password");
}
}
}
<PRODUCT_HOME>/repository/component/lib/
directory or the OSGI bundle to the <PRODUCT_HOME>/repository/component/dropins/ directory
. master-datasources.xml
file with an alias name and your Secret Callback handler class name. For example,<datasource>
<name>WSO2_CARBON_DB</name>
<description>The datasource used for registry and user manager</description>
<jndiConfig>
<name>jdbc/WSO2CarbonDB</name>
</jndiConfig>
<definition type="RDBMS">
<configuration>
<url>jdbc:h2:repository/database/WSO2CARBON_DB;DB_CLOSE_ON_EXIT=FALSE;LOCK_TIMEOUT=60000</url>
<username>wso2carbon</username>
<passwordsvns:secretAlias="Datasources.WSO2_CARBON_DB.Configuration.Password">password</password>
<driverClassName>org.h2.Driver</driverClassName>
<maxActive>50</maxActive>
<maxWait>60000</maxWait>
<testOnBorrow>true</testOnBorrow>
<validationQuery>SELECT 1</validationQuery>
<validationInterval>30000</validationInterval>
</configuration>
</definition>
</datasource>
<PRODUCT_HOME>/repository/conf/security/secret-conf.properties
file with your Secret Callback handler class name.
Secrets and alias list in Carbon configurations
Following are the alias names and secrets of carbon configuration files which are supported by Secure Vault.
transports.https.keystorePass -> SSL key and keystore password in mgt-transport.xml Carbon.Security.KeyStore.Password- > Keystore password of Carbon server in carbon.xml Carbon.Security.KeyStore.KeyPassword -> Private key password of Carbon server in carbon.xml Carbon.Security.TrustStore.Password -> Trust store password of Carbon server in carbon.xml UserManager.AdminUser.Password -> Admin User password in user-mgt.xml Datasources.WSO2_CARBON_DB.Configuration.Password -> User management and registry database connection password in master-datasources.xml UserStoreManager.Property.ConnectionPassword -> User store connection password in user-mgt .xml Axis2.Https.Listener.TrustStore.Password -> NIO Listener SSL trust store password in axis2.xml Axis2.Https.Listener.KeyStore.Password -> NIO Listener SSL keystore store password in axis2.xml Axis2.Https.Listener.KeyStore.KeyPassword -> NIO Listener SSL key password in axis2.xml Axis2.Https.Sender.TrustStore.Password -> NIO Sender SSL trust store password in axis2.xml Axis2.Https.Sender.KeyStore.Password -> NIO Sender SSL key store password in axis2.xml Axis2.Https.Sender.KeyStore.KeyPassword -> NIO Sender SSL key password in axis2.xml Axis2.Mailto.Parameter.Password -> Email sender password in axis2.xml