Configure SSL for java.net.URL HTTPS protocol
The java.net.URL class provides a direct connection to the Web server to retrieve the specified URL using the HTTPS protocol.
Configure SSL for the Web server depends on the type of Web server. Consult your Web server documentation for instructions.
Configure the client Java keystore
If you already have a client Java keystore file that is populated with the required personal and signer certificates, you can omit this step.
To configure the client Java keystore, use Digital Certificate Manager (DCM) to extract the Local Certificate Authority (CA) certificate that is used by the Web server. You can then import the certificate into the client Java keystore file.
Perform these steps:
- Start the Digital Certificate Manager (DCM).
- Create a Local Certificate Authority (CA). If you already have a certificate authority created on your iSeries system, skip this step.
- On the left pane, click Select a Certificate Store.
- Select *System and click Continue.
- On the Certificate Store and Password page, enter the password, then click Continue.
- In the left pane, click Install CA certificate on your PC.
- In the right pane, click Copy and paste certificate.
- Create text file USER_INSTALL_ROOT/etc/myLocalCA.txt on your PC, then paste the CA certificate into myLocalCA.txt and save the file. Ensure that the copy of the CA certificate ends with the new line character.
- Click the Done button.
Next, create a new key database file for the client Https application:
Start iKeyman on your workstation. For more information, see IBM Key Managment Tool (iKeyman).
- Create a new key database file:
- Click Key Database File and select New.
- Specify settings:
- Key database type: JKS
- File Name: httpsClientKeys.jks
- Location: your etc directory, such as
USER_INSTALL_ROOT/etc/myKeys
- Click OK.
- Enter a password (twice for confirmation) and click OK.
Delete all of the signer certificates.
Click Signer Certificates and select Personal Certificates.
- Add a new self-signed certificate:
- Click New Self-Signed to add a self-signed certificate.
- Specify settings:
- Key Label: httpsClientTest
- Common Name: use the DNS name for your iSeries server
- Organization: IBM
- Click OK.
- Extract the certificate from this self-signed certificate so that it can be imported into the Web server's SSL key file:
- Click Extract Certificate.
- Specify settings:
- Data Type: Base64-encoded ASCII data
- Certificate file name: httpsClient.arm
- Location: the path to your etc directory
- Click OK.
- Import the Web server's certificate:
- Click Personal Certificates and select Signer Certificates.
- Click Add.
- Specify settings:
- Data Type: Base64-encoded ASCII data
- Certificate file name: myLocalCA.txt
- Location: the path to your etc directory
- Click OK.
Enter web-server for the label and click OK.
Click Key Database File.
Select Exit.
Configure the Web server's certificate store
Add the signer certificate of the client HTTPS application to the Web server's SSL key file and to the list of trusted CA certificates for the Web server's secure application. This step is needed if the Web server configuration requires client authentication:
- Start the Digital Certificate Manager (DCM).
- On the left pane, click Select a Certificate Store
- Select *SYSTEM and click Continue.
- On the Certificate Store and Password page, enter the password, then click Continue.
- On the left pane, click Fast Path.
- Select Work with CA certificates.
- Click the Import button.
- Specify USER_INSTALL_ROOT/etc/httpsClient.arm for the Import file: field value and click Continue.
- Specify httpsClient for the CA certificate label field value and click Continue.
- On the left pane, select Work with server applications. On this page, select the application used by the Web server's configuration, and click Work with Application.
- Click Define CA Trust List.
- Click the check box for the httpsClient CA, then click OK.
Configure WebSphere Application Server
You must specify some Java virtual machine properties for the application server. Use the WebSphere administrative console to perform these steps:
- In the navigation menu, expand Servers, and click Application Servers.
- In the Application Servers page, click the name of your server.
- Under Additional Properties, click Process Definition.
- Under Additional Properties, click Java Virtual Machine.
- Under Additional Properties, click Custom Properties.
Click New to a new property. Add these properties:
Name Value java.protocol.handler.pkgs com.ibm.net.ssl.internal.www.protocol javax.net.ssl.trustStore USER_INSTALL_ROOT/etc/httpsClientKeys.jks, where USER_INSTALL_ROOT is the root directory of your instance javax.net.ssl.trustStorePassword (Enter your password.) If the Web server requires client authentication, you need to additionally specify these properties:
Name Value javax.net.ssl.keyStore USER_INSTALL_ROOT/etc/httpsClientKeys.jks, where USER_INSTALL_ROOT is the root directory of your instance. javax.net.ssl.keyStorePassword (Enter your password.) Normally, javax.net.ssl.keyStore would be a different keystore file.
Click OK.
For a code example of a servlet that uses HTTPS, see Example: HTTPS servlet. The servlet retrieves the URL to display entered as a query string or as a servlet initialization parameter.