Friday, December 17, 2010

Installing SSL certificates on GlassFish

Scenario: Java EE programs run on a GlassFish server and exchange web service messages with remote servers using SSL. The remote servers' SSL certificates must be imported to the glass fish server trusted certificate store.
  1. Use any browser to save the SSL certicate to personal certificates store.
  2. Run mmc and add certificates snapin (File/Add Remove Snapin) .
  3. View certificate saved in step 1 and export to a file, for example c:\GlassFish_Server_3\glassfish\domains\domain1\config\webservice1.cer
  4. Import to glassfish trusted domain cacerts. Example code below:
    cd c:\GlassFish_Server_3\glassfish\domains\domain1\config
    "c:\Java\jdk1.6.0_21\bin\keytool" -delete -trustcacerts -alias register_webservice_1 -keystore cacerts.jks
    "c:\Java\jdk1.6.0_21\bin\keytool" -import -trustcacerts -alias register_webservice_1 -file server.cer -keystore cacerts.jks
    
    Keystore password is "changeit", no quotes
  5. Modify DNS or hosts file to map the common name in SSL certificate to the ip address