此内容没有您所选择的语言版本。
Chapter 18. Encrypting the Keystore Password in a Tomcat Connector
JBoss Web is based on Apache Tomcat.
SSL with Tomcat requires a secure connector. This means that the keystore/truststore password cannot be passed as an attribute in the connector element of Tomcat's
server.xml file.
A working understanding of the JaasSecurityDomain that supports keystores, truststores, and password based encryption is advised.
Refer to Chapter 13, Secure Remote Password Protocol and Chapter 17, Encrypting Data Source Passwords for supporting information and related procedures.
Procedure 18.1. Encrypt Tomcat Container Keystore Password
Append connector element
Add a connector element inserver.xmlin$JBOSS_HOME/server/$PROFILE/deploy/jbossweb.sar.Copy to Clipboard Copied! Toggle word wrap Toggle overflow Configure JaasSecurityDomain MBean
Set the JaasSecurityDomain MBean in the$JBOSS_HOME/server/$PROFILE/deploy/security-service.xmlfile.If the file does not exist, create it. The code sample in Example 18.1, “security-service.xml” shows the content you need to add to a newly-createdservice-security.xmlfile. If thesecurity-service.xmlfile exists, append the <mbean> element block to the file.Example 18.1. security-service.xml
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Note
If the keystore contains multiple certificates, you can use the ServerAlias property. The property value specifies the alias of the certificate retrieved by the SSL connector.<attribute name="ServerAlias">ssl</attribute>
<attribute name="ServerAlias">ssl</attribute>Copy to Clipboard Copied! Toggle word wrap Toggle overflow The Salt and IterationCount are the variables that define the strength of your encrypted password, so you can vary it from what is shown. Ensure you record the new values, and use when generating the encrypted password.Note
The Salt must be at least eight characters long.Generate encrypted password
The <mbean> configuration specifies that the keystore is stored in thejboss-as/server/$PROFILE/conf/localhost.keystorefile. The <mbean> also specifies the encrypted password file is stored injboss-as/server/$PROFILE/conf/keystore.passwordfile.You must create thelocalhost.keystorefile.Execute the following command in thejboss-as/server/$PROFILE/confdirectory.java -cp $JBOSS_HOME/lib/jbosssx.jar \org.jboss.security.plugins.FilePassword welcometojboss 13 unit-tests-server keystore.password
[conf]$ java -cp $JBOSS_HOME/lib/jbosssx.jar \org.jboss.security.plugins.FilePassword welcometojboss 13 unit-tests-server keystore.passwordCopy to Clipboard Copied! Toggle word wrap Toggle overflow This command uses jbosssx.jar as the classpath (-cp) and the FilePassword security plug-in to create akeystore.passwordfile with the password set asunit-tests-server. To verify you have permission to create akeystore.passwordfile, you supply the salt and iteration parameters configured in the <mbean> <attribute> elements of the JaasSecurityDomain.You execute this command in the/confdirectory so thekeystore.passwordfile is saved to this directory.Update the Tomcat service MBean
Navigate to$JBOSS_HOME/server/$PROFILE/deploy/jbossweb.sar/META-INF/.Openjboss-beans.xmland append the following <depends> tag to theWebServerend of the file. Adding the <depends> tag specifies that Tomcat must start afterjboss.security:service=PBESecurityDomain.Copy to Clipboard Copied! Toggle word wrap Toggle overflow
Example 18.2. JaasSecurityDomain definition for pkcs12 keystores
Based on Procedure 18.1, “Encrypt Tomcat Container Keystore Password”, pkcs12 keystore containers referenced by the Tomcat Connector would look similar to this example.
18.1. Medium Security Usecase 复制链接链接已复制到粘贴板!
复制链接链接已复制到粘贴板!
A user does not want to encrypt the keystore password but wants to externalize it (outside of
server.xml ) or wants to make use of a predefined JaasSecurityDomain.
Procedure 18.2. Predefined JaasSecurityDomain
Update jboss-service.xml to add a connector
Navigate to$JBOSS_HOME/server/, and add the following code block to the$PROFILE/deploy/jbossweb.sar/META-INFjboss-service.xmlfile.Copy to Clipboard Copied! Toggle word wrap Toggle overflow Add a <depends> tag to the Tomcat service
Navigate to$JBOSS_HOME/server/$PROFILE/deploy/jbossweb.sar.Openserver.xmland append the following <depends> element toward the end of the file:<depends>jboss.security:service=SecurityDomain</depends> </mbean> </server>
<depends>jboss.security:service=SecurityDomain</depends> </mbean> </server>Copy to Clipboard Copied! Toggle word wrap Toggle overflow Define the JaasSecurityDomain MBean in a *-service.xml file
security-service.xmlin the deploy directory, for example.Copy to Clipboard Copied! Toggle word wrap Toggle overflow
Note
If you see this error, remember the keystore file should be writable by the user id that is running JBoss Enterprise Application Platform.