15.2.2. Configure a client to accept a self-signed server certificate
Procedure 15.3. Import the certificate to the trust store "localhost.truststore"
- Issue the following command on the client:
keytool -import -alias ejb-ssl -file mycert.cer -keystore localhost.truststore
- Enter the password for this trust store if it already exists; otherwise enter and re-enter the password for a new trust store.
- Verify the details of the certificate. If it is the correct one, type 'yes' to import it to the trust store.Result:
The certificate is imported to the trust store, and a secure connection can now be established with a server that uses this certificate.
Now that you have imported the self-signed server certificate to a trust store on the client, you must instruct the client to use this trust store. Do this by passing the localhost.truststore
location to the application using the javax.net.ssl.trustStore
property, and the trust store password using the javax.net.ssl.trustStorePassword
property. Example 15.1, “Invoking the com.acme.Runclient application with a specific trust store” is an example command that invokes the application com.acme.RunClient , a hypothetical application that makes remote method calls to an EJB on a JBoss Application Server. This command is run from the root of the application's package directory (the directory containing com
directory in the file path com/acme/RunClient.class
).
Example 15.1. Invoking the com.acme.Runclient application with a specific trust store
java -cp $JBOSS_HOME/client/jbossall-client.jar:. -Djavax.net.ssl.trustStore=${resources}/localhost.truststore \ -Djavax.net.ssl.trustStorePassword=TRUSTSTORE_PASSWORD com.acme.RunClient