Content Server Manual / Version 2010
Table Of ContentsIn order to encrypt passwords stored in property files you can use the KeyStore based encryption service. This service uses a pair of public and private keys to encode and decode passwords. The keys are retrieved from a KeyStore located in the file system.
Preliminary Setup
Before you can use the KeyStore based encryption service, you have to create a KeyStore file using the Java
keytool
command. The KeyStore file will contain the private key and the certificate that will be
used to encrypt and decrypt the passwords. On the command prompt type:
keytool -genkey -alias <KEY_ALIAS> -keyalg RSA -validity 3650 -keystore <KEYSTORE_FILENAME>
The tool will ask you for the KeyStore password and the key password.
It will also ask you for your user name, organizational unit, organization, city, state/province, country code. This information (which goes into your self-signed certificate) is not relevant for the correct functioning of your KeyStore. The resulting key/certificate will be valid for 3650 days (about 10 years). It is assumed that this should be enough for your CM installation.
Having the KeyStore created, the KeyStore credentials now have to be stored in a password file, so that the servers and clients can access the KeyStore without prompting for passwords. The password file is in Java properties file format and has to contain the following entries:
CM_KEYSTORE_PASSWORD=<KEYSTORE_PASSWORD> CM_KEY_ALIAS=<KEY_ALIAS> CM_KEY_PASSWORD=<KEY_PASSWORD>
As the password file will contain the clear text passwords for your KeyStore, the file has to be protected from unauthorized access. This could be done for example by setting reasonable access rights for the file, or by putting it on a removable device.
In order to use the KeyStore with the Encryption Service, you have two options:
By default, the service expects
the KeyStore file under the path
${user.home}/.cmservices/.keystore
and the password file under
${user.home}/.cmservices/.keystore.properties
If you want store the files under different paths you have to provide the following two system properties:
CM_KEYSTORE_LOCATION
: location of the KeyStore fileCM_KEYSTORE_PASSWORD_FILE_LOCATION
: location of the password file
Password Encryption
For each password you want to encrypt take the following steps:
Login as a user who can access the KeyStore and password file. Switch to the installation directory of the command line tools and enter the following command where
<plaintextpassword>
should be replaced with the password you want to encrypt:
bin/cm encryptpasswordproperty <plaintextpassword>
The command output is the encrypted password (which includes the curly brackets!) and some informational text. Use the
-r
option (bin/cm encryptpasswordproperty -r <plaintextpassword>
) to have the tool just dump out the encrypted password without other information.
Note
The tool will generate a unique value for the same plain text value each time you invoke it.
Copy the password (including the curly brackets) into your respective properties file. You can append a comment after the closing curly bracket to add information. For example:
sql.store.password={G/7UZ7hPQnGZ/xX4J/7b8FNp/ybEH/JU Qp5c8NRoDEQSlK5ypbkwotfu6j8U1SHr QifmKeAQUvou/+ES34/pRHs=} --- generated by User xxx on 28/03/2013
Verify a password
If you want to verify that a given encrypted password actually represents a given plaintext password, use
cm encryptpasswordproperty -c <plaintext password> <encrypted entry>
where <plaintext password>
should be replaced with the password and <encrypted
entry>
with the result of the encryption tool. The command will provide you with textual information
whether these passwords match. The command returns with return value "0" whether the tokens match or not.
Troubleshooting
You must set the CM_KEYSTORE_LOCATION
and CM_KEYSTORE_PASSWORD_FILE_LOCATION
system properties not only for the encryptpasswordproperty
tool, but also for the tool
that uses the encrypted password, for instance schemaaccess
.
View the respective component's log file. If an encrypted password cannot be decoded, you will see an error message in your log file telling you so. Since passwords decryption is verified early on (fail fast), you will find the error messages shortly after the component, service, or server starts.