此内容没有您所选择的语言版本。
Chapter 8. Using a Password Vault with Red Hat JBoss Web Server 3
A password vault is used to mask passwords and other sensitive strings, and store them in an encrypted Java keystore. This allows you to eliminate storing clear-text passwords in your Tomcat configuration files, as Tomcat can lookup passwords and other sensitive strings from a keystore using the vault.
The examples and commands below use JWS_HOME as the JBoss Web Server installation directory. Replace JWS_HOME with the path to your JBoss Web Server installation. Also, the paths below use / for directory separators.
8.1.1. Installing the JBoss Web Server password vault 复制链接链接已复制到粘贴板!
There are two methods of installing the JBoss Web Server password vault:
-
Installing the JBoss Web Server password vault on Red Hat Enterprise Linux from an RPM (For Red Hat Enterprise Linux systems where JBoss Web Server was installed using
yumonly). - Downloading and Extracting the Vault Files from a .zip archive (Available for all JBoss Web Server installations).
Where the JBoss Web Server has been installed from RPMs on Red Hat Enterprise Linux, install the password vault as the root user by executing:
yum install tomcat-vault tomcat-vault-tomcat<VERSION>
yum install tomcat-vault tomcat-vault-tomcat<VERSION>
Where <VERSION> is either 7 for tomcat 7 (tomcat-vault-tomcat7) or 8 for tomcat 8 (tomcat-vault-tomcat8).
In the tomcat-vault RPM installation, the vault jar is located in /usr/share/java/vault-tomcat-<VERSION>-jar-with-dependencies.jar. This jar can be used in JWS zip installation: JWS_HOME/tomcat_<VERSION>_/lib/ For JWS RPM installation: /usr/share/tomcat<VERSION>/lib.
- Stop Tomcat if it is running.
-
Extract the contents of the vault zip to your
JWS_HOMEdirectory. In this topic,JWS_HOME/tomcat-vaultwill refer to the extracted vault directory. -
Copy
JWS_HOME/tomcat-vault/modules/system/layers/base/tomcat-vault/main/tomcat-vault.jartoJWS_HOME/tomcat<VERSION>/lib/. EditJWS_HOME/tomcat<VERSION>/conf/catalina.properties, and add the following line:
org.apache.tomcat.util.digester.PROPERTY_SOURCE=org.apache.tomcat.vault.util.PropertySourceVault
org.apache.tomcat.util.digester.PROPERTY_SOURCE=org.apache.tomcat.vault.util.PropertySourceVault
8.1.2. Creating a Java Keystore 复制链接链接已复制到粘贴板!
To use a password vault, you must first create a Java keystore. You can do this using the keytool -genseckey command. For example:
keytool -genseckey -keystore JWS_HOME/tomcat/vault.keystore -alias my_vault -storetype jceks -keyalg AES -keysize 128 -storepass <vault_password> -keypass <vault_password> -validity 730
$ keytool -genseckey -keystore JWS_HOME/tomcat/vault.keystore -alias my_vault -storetype jceks -keyalg AES -keysize 128 -storepass <vault_password> -keypass <vault_password> -validity 730
The values above are examples only. Replace them with values specific to your environment.
For an explanation of the parameters, use the keytool -genseckey -help command.
This feature was introduced by JBoss Web Server 3.1 Service Pack 2.
The vault.properties file for the tomcat-vault can be stored outside of JWS_HOME/tomcat<VERSION>/conf/ in a CATALINA_BASE/conf/ directory (if set).
To set the CATALINA_BASE directory, follow the instructions in the section 'Advanced Configuration - Multiple Tomcat Instances' in the Running The Apache Tomcat 8.0 Servlet/JSP Container document found on the Apache Tomcat Website.
The default location for CATALINA_BASE is JWS_HOME/tomcat<VERSION>/ (also known as CATALINA_HOME).
For more information on setting CATALINA_BASE, see:
8.1.4. Initializing the Password Vault 复制链接链接已复制到粘贴板!
The vault must be initialized before it can be used to store sensitive strings. This is done using the JWS_HOME/tomcat-vault/bin/tomcat-vault.sh vault script. For Microsoft Windows, the script is tomcat-vault.bat.
The script can be run interactively or non-interactively. Below is an example of an interactive execution of the script to initialize a password vault, with the values shown below using the example keystore from the previous step.
The values below are examples only. Replace them with values appropriate for your environment.
Note the output for the Tomcat properties file, as you will need this to configure Tomcat to use the vault.
Configuring Tomcat to Use the Password Vault
In JWS_HOME/tomcat<VERSION>/conf/, create a file named vault.properties containing the vault configuration produced when initializing the vault. The values provided below use the example vault initialized in the previous steps.
For KEYSTORE_PASSWORD, you must use the masked value that was generated when initializing the vault.
The Vault for Apache Tomcat can be created non-interactively by providing the required input as arguments to the tomcat-vault.sh script. The vault.properties file is also created as output of the tomcat-vault.sh script when the -g, --generate-config option is used.
The values below are examples only. Replace them with values appropriate for your environment.
8.1.5. Storing a Sensitive String in the Password Vault 复制链接链接已复制到粘贴板!
The vault script used in the previous steps is also used to store sensitive strings in the password vault. The script can be run interactively or non-interactively.
When adding a string to a password vault, the sensitive string needs a name that it will be referred by. For a password vault, this name is called an attribute name, and the password itself is called a secured attribute.
The example below demonstrates using the vault script non-interactively to store a password. It uses the vault that was initialized in the previous steps, and stores the sensitive string P@SSW0#D with the attribute name manager_password.
JWS_HOME/tomcat-vault/bin/tomcat-vault.sh --keystore JWS_HOME/tomcat-vault/vault.keystore --keystore-password <vault_password> --alias my_vault --enc-dir JWS_HOME/tomcat-vault/ --iteration 120 --salt 1234abcd --vault-block my_block --attribute manager_password --sec-attr P@SSW0#D
$ JWS_HOME/tomcat-vault/bin/tomcat-vault.sh --keystore JWS_HOME/tomcat-vault/vault.keystore --keystore-password <vault_password> --alias my_vault --enc-dir JWS_HOME/tomcat-vault/ --iteration 120 --salt 1234abcd --vault-block my_block --attribute manager_password --sec-attr P@SSW0#D
You can optionally specify a vault block to store the password in. If you don’t specify a block, one will be automatically created for you. In the above example, my_block is used.
After storing a sensitive string in the password vault, you can refer to it in your configuration files by entering the stored string’s attribute as ${VAULT::block_name::attribute_name::}.
For example, to use the password stored in the previous steps, replace:
<user username="manager" password="P@SSW0#D" roles="manager-gui"/>
<user username="manager" password="P@SSW0#D" roles="manager-gui"/>
with:
<user username="manager" password="${VAULT::my_block::manager_password::}" roles="manager-gui"/>
<user username="manager" password="${VAULT::my_block::manager_password::}" roles="manager-gui"/>
As a result, only a reference to the password is visible in the Tomcat configuration file, and the actual password is only stored in the password vault.