Configuration
Start by going to the WebLogic console. If you accept the default settings when you install your domain (the place where you'll run servers and deploy code), the admin port is 7001. For example, my admin server is found here:
http://localhost:7001/console
Figure 1 shows how the console looks after logging in.
Figure 1 WebLogic 8.1 console after login.
In the left pane, click the plus (+) next to Servers to display a list of all the servers available in the domain. For this example, we'll use the admin server, usually named myserver in a default configuration. Click your admin server to display its configuration in the right pane (see Figure 2). On the Configuration tab, click the Keystores & SSL tab (see Figure 3).
Figure 2 The default console view of my admin server.
Figure 3 The Keystores & SSL tab for my admin server.
We're going to specify a custom-made keystore for our configuration. Click the Change link in the upper-right portion of the configuration items. Figure 4 shows the resulting drop-down list of options for configuration:
- Demo Identity and Demo Trust. These are the certificates that I mentioned earlier. The Demo Trust simply contains the root certificate for the demo certificate authority. By default, if you're using Node Manager, the demo certificates are used.
- Custom Identity and Java Standard Trust. The custom identity is simply a keystore that you create. The Java Standard Trust refers to the trusted keystore included in most JDKs. In the Sun JDK and BEA's JRockit JVM, you can find a file called cacerts in jre/lib/security directory. The password to this keystore is changeit.
- Custom Identity and Custom Trust. This is the same identity configuration as above, but with this option you also provide a custom trust. If your server is engaging in two-way SSL calls as a client or a server, the custom trust is how your server will determine whether it should trust the certificate that the peer presents. If you're accepting client certificates, it's a good idea to build your own trust, which limits the certificates that can be presented to ones that are issued by the certificate authorities of your choice. The cacerts file has approximately 30 root certificates. If you're only trying to establish plain old one-way SSL, you needn't worry about this option or the next.
- Custom Identity and Command Line Trust. Same identity as previously discussed, but this time the trust will be supplied on the command line. This option can be useful if you're going to switch trusts often and don't want to continually use the console or edit the config.xml file.
Figure 4 Choose Custom Identity and Java Standard Trust from the list.
Figure 5 The first step in the SSL configuration, where you specify your identity keystore information.
For this article, we'll select Custom Identity and Java Standard Trust. Figure 5 shows the resulting options: text fields specifying the properties of the custom identity keystore and the Java Standard Trust passphrase. My keystore is located here, for example:
D:\MyData\solutions\my_keystores\verisign-example\verisign-keystore.jks
The Keystore Type entry refers to the provider of the keystore structure. If you didn't create the keystore yourself, ask the provider what the type is. In most cases, it will be JKS, which is Sun's implementation. Then enter the password for the keystore. (Don't confuse this with your private key password; we'll enter that later.)
Enter the Java Standard Trust password. Unless you or your system administrator changed it, the password will be changeit. Click Continue.
On the following screen (see Figure 6), enter the private key alias. This is the unique identifier in the keystore for your private key. If you don't know the alias, you should be able to figure it out by going to the directory where the keystore is and running the following command:
keytool -list -v -keystore keystore-name
In my environment, here's the output:
D:\MyData\solutions\my_keystores\verisign-example>keytool -list -v -keystore verisign-keystore.jks Enter keystore password: weblogic Keystore type: jks Keystore provider: SUN Your keystore contains 1 entry Alias name: servercert Creation date: Mar 6, 2005 Entry type: keyEntry Certificate chain length: 2 Certificate[1]: Owner: CN=jsvede, OU=Support, O=BEA Systems Inc, L=Denver, ST=Colorado, C=US Issuer: OU=For VeriSign authorized testing only. No assurances (C)VS1997, OU=http://www.verisign.com/repository/TestCPS Incorp. By Ref. Liab. LTD., O="V eriSign, Inc" Serial number: 46b06fa66a04d6318949659fc4d2bb50 Valid from: Thu Feb 10 17:00:00 MST 2005 until: Fri Feb 25 16:59:59 MST 2005 Certificate fingerprints: MD5: 2A:B5:9D:41:91:25:4C:A8:54:02:A1:F0:36:F1:3C:B4 SHA1: 44:3B:E6:77:82:FD:C8:B8:0A:06:04:79:BC:67:7C:AC:1E:F1:D3:2C Certificate[2]: Owner: OU=For VeriSign authorized testing only. No assurances (C)VS1997, OU=http://www.verisign.com/repository/TestCPS Incorp. By Ref. Liab. LTD., O="Ve riSign, Inc" Issuer: OU=For VeriSign authorized testing only. No assurances (C)VS1997, OU=http://www.verisign.com/repository/TestCPS Incorp. By Ref. Liab. LTD., O="V eriSign, Inc" Serial number: 52a9f424da674c9daf4f537852abef6e Valid from: Sat Jun 06 18:00:00 MDT 1998 until: Tue Jun 06 17:59:59 MDT 2006 Certificate fingerprints: MD5: 40:06:53:11:FD:B3:3E:88:0A:6F:7D:D1:4E:22:91:87 SHA1: 93:71:C9:EE:57:09:92:5D:0A:8E:FA:02:0B:E2:F5:E6:98:6C:60:DE ******************************************* *******************************************
Figure 6 Private key information. Remember that the password for the private key may differ from the one for the keystore.
Depending on the keystore, you can probably derive the value by looking for the listing where the Entry type is keyEntry, and then looking at the alias for it:
Alias name: servercert Creation date: Mar 6, 2005 Entry type: keyEntry Certificate chain length: 2
The alias I used is servercert. Keep in mind that one keystore can contain more than one key, so it may not be that easy. However, if you create the keystore from scratch it will be straightforward.
Something to keep in mind is that when you do a listing of the keystore using keytool, it will prompt you for the password. You don't need to know the password to see the contents of a keystore. If you don't, the keytool will provide the following warning:
D:\MyData\solutions\my_keystores\verisign-example>keytool -list -v -keystore verisign-keystore.jks Enter keystore password: ***************** WARNING WARNING WARNING ***************** * The integrity of the information stored in your keystore * * has NOT been verified! In order to verify its integrity, * * you must provide your keystore password. * ***************** WARNING WARNING WARNING *****************
This warning lets you know that keytool cannot verify the authenticity of the keystore without the password. Specify the password when prompted.
After you enter the alias and the password, you're ready to test your configuration.
Testing the Configuration
Stop your server and edit your startWeblogic.cmd or startWebLogic.sh file. We need to change the logging level of the server, enable debugging to the standard output, and set the logging level to Info. This can actually be done through the console, but there is a specific SSL debugging flag that can only be set through the script, so it's just as easy to modify the start script for the other settings as well.
Open your script and make the changes listed below in bold:
set SERVER_NAME=admin set CLASSPATH=%WEBLOGIC_CLASSPATH%;%POINTBASE_CLASSPATH%;%JAVA_HOME%\jre\lib\rt.jar;%WL_HOME%\server\lib\webservices.jar;%CLASSPATH% set JAVA_OPTIONS=-Dweblogic.StdoutSeverityLevel=64 -Dweblogic.StdoutDebugEnabled=true -Dssl.debug=true @REM Call WebLogic Server echo . echo CLASSPATH=%CLASSPATH% echo . echo PATH=%PATH% echo . echo *************************************************** echo * To start WebLogic Server, use a username and * echo * password assigned to an admin-level user. For * echo * server administration, use the WebLogic Server * echo * console at http:\\[hostname]:[port]\console * echo *************************************************** %JAVA_HOME%\bin\java %JAVA_VM% %MEM_ARGS% %JAVA_OPTIONS% -Dweblogic.Name=%SERVER_NAME% -Dweblogic.ProductionModeEnabled=%PRODUCTION_MODE% -Djava.security.policy="%WL_HOME%\server\lib\weblogic.policy" weblogic.Server
Now restart the server. You'll know if you have added the flags correctly because the server begins producing a lot of output. To confirm that the flags have been accepted, look at the beginning of the output at startup, and you'll see this:
*************************************************** * To start WebLogic Server, use a username and * * password assigned to an admin-level user. For * * server administration, use the WebLogic Server * * console at http:\\[hostname]:[port]\console * *************************************************** <Mar 6, 2005 12:45:41 PM MST> <Info> <WebLogicServer> <BEA-000377> <Starting WebLogic Server with Java HotSpot(TM) Client VM Version 1.4.2_05-b04 from Sun Microsystems Inc.> <Mar 6, 2005 12:45:41 PM MST> <Debug> <TLS> <000000> <Enabled muxing IO for SSL in server> <Mar 6, 2005 12:45:41 PM MST> <Info> <Configuration Management> <BEA-150016> <This server is being started as the administration server.>
How can you tell if your keystore is loaded? Look for the following in the debugging output:
<Mar 6, 2005 1:23:02 PM MST> <Debug> <TLS> <000000> <SSLManager: getting server private key> <Mar 6, 2005 1:23:02 PM MST> <Notice> <Security> <BEA-090170> <Loading the private key stored under the alias servercert from the jks keystore fi le D:\MyData\solutions\my_keystores\verisign-example\verisign-keystore.jks.> <Mar 6, 2005 1:23:02 PM MST> <Debug> <TLS> <000000> <SSLManager.getServerCertificate()> <Mar 6, 2005 1:23:02 PM MST> <Notice> <Security> <BEA-090171> <Loading the identity certificate stored under the alias servercert from the jks ke ystore file D:\MyData\solutions\my_keystores\verisign-example\verisign-keystore.jks.> <Mar 6, 2005 1:23:02 PM MST> <Notice> <WebLogicServer> <BEA-000298> <Certificate expires in 14 days: [
Additionally, near the end of the output will be more information about whether the configuration changes were successful:
<Mar 6, 2005 1:23:08 PM MST> <Info> <WebLogicServer> <BEA-000300> <Certificate contents: 2 certificate(s): fingerprint = c597c372b1ebe10124382d5f32a40239, not before = Sat Mar 05 17:00:00 MST 2005, not after = Sun Mar 20 16:59:59 MST 2005, holder = C =US SP=Colorado L=Denver O=BEA Systems Inc OU=Support CN=jsvede , issuer = O=VeriSign, Inc OU=For VeriSign authorized testing only. No assurances (C)VS1997 , key = modulus length=129, exponent length=3 fingerprint = 40065311fdb33e880a6f7dd14e229187, not before = Sat Jun 06 18:00:00 MDT 1998, not after = Tue Jun 06 17:59:59 MDT 2006, holder = O =VeriSign, Inc OU=For VeriSign authorized testing only. No assurances (C)VS1997 , issuer = O=VeriSign, Inc OU=For VeriSign authorized testing onl y. No assurances (C)VS1997 , key = modulus length=65, exponent length=3 > ... <Mar 6, 2005 1:23:08 PM MST> <Notice> <WebLogicServer> <BEA-000360> <Server started in RUNNING mode> <Mar 6, 2005 1:23:08 PM MST> <Notice> <WebLogicServer> <BEA-000355> <Thread "SSLListenThread.Default" listening on port 7002, ip address *.*>
The only step left is to try accessing your server over the SSL port. The easiest way to test this is to access the console over the secure port.
Configuring Without the Console
Suppose you don't like using a GUI for configuration. You can actually do all of this work in the config.xml file—the configuration file in which WebLogic 8.1 stores the configuration information that's in the console. For example, here's my <Server> stanza after I've started the server for the first time:
<Server ListenAddress="" ListenPort="7001" Name="admin" NativeIOEnabled="true" ServerVersion="8.1.4.0" StdoutSeverityLevel="64" StuckThreadMaxTime="60" StuckThreadTimerInterval="60"> <SSL Enabled="true" HostnameVerificationIgnored="false" IdentityAndTrustLocations="KeyStores" Name="admin"/> </Server>
Here it is again, after I've made all the changes in the console (obviously there are a lot of additions, shown here in bold):
<Server CustomIdentityKeyStoreFileName="D:\MyData\solutions\my_keystores\verisign-example\verisign-keystore.jks" CustomIdentityKeyStorePassPhraseEncrypted="{3DES}OoO7mtolODVhXfQVNGO+8Q==" CustomIdentityKeyStoreType="jks" JavaStandardTrustKeyStorePassPhraseEncrypted="{3DES}kFL3FTkIpZgW+fJrYYO58w==" KeyStores="CustomIdentityAndJavaStandardTrust" ListenAddress="" ListenPort="7001" Name="admin" NativeIOEnabled="true" ServerVersion="8.1.4.0" StdoutSeverityLevel="64" StuckThreadMaxTime="60" StuckThreadTimerInterval="60"> <SSL Enabled="true" HostnameVerificationIgnored="false" IdentityAndTrustLocations="KeyStores" Name="admin" ServerPrivateKeyAlias="servercert" ServerPrivateKeyPassPhraseEncrypted="{3DES}OoO7mtolODVhXfQVNGO+8Q=="/> </Server>
You can replace any of the encrypted passwords with clear text; when the server is restarted, the text will be encrypted. (Be careful not to leave the password unencrypted for very long, though.)
Troubleshooting
Like everything else in life, SSL configuration rarely goes as smoothly as I just described. Here are some common problems:
- Incomplete certificate chain. Users often are missing the root certificate or an intermediate certificate when they build their keystore. You should be able to go from your public certificate's issuer to the subject of the intermediate certificate, and then from the intermediate certificate's issuer to the subject of the root certificate. If you can't, you're going to have problems.
- Private key/public certificate mismatch. This problem can be tricky to diagnose, so my advice is to keep close track of private keys and certificate-signing requests, and sign certificates very carefully. If you have mismatched certificates, your public certificate will have to be reissued.
- Migrating from an earlier version of WebLogic. In version 6.1, private keys didn't require a password; therefore, many people didn't supply one. Although WebLogic ships with a utility called wlkeytool to help encrypt the private key, there are a variety of situations in which this utility doesn't work. In general, if you run into a problem with encrypting the private key, it's easier to rebuild the private key in a keystore specifically for WebLogic.
- Proprietary certificate authorities. If you work for a bank or financial institution, government contractor, or government, or your company is using OpenSSL, you may encounter other issues that can cause a keystore or private key to cause problems in WebLogic Server. Sometimes it's a compliance issue in which the certificate that's signed by the CA is incorrect, or the problem may be the encoding of certain characters in the certificate. If you're having problems with your keys or certificates, you may need to call for support.