Multiple SSL certificates with Glassfish and Apache front.

This article describe how to set up SSL for Apache in front of Glassfish as was explained here.

Thus, we assume you followed the previous steps and now have your Apache front and Glassfish working well for HTTP traffic. The following steps will allow you to handle multiple SSL certificates for your Glassfish sites, which was a SNI issue we covered here.

First, we will open the C:\xampp\apache\conf\extra\httpd-ssl.conf file and add this:

<VirtualHost *:443>
ServerName somedomain.com
ServerAlias www.somedomain.com
JkMount /* worker1
SSLEngine on
SSLCertificateFile certs/www.somedomain.com/www_somedomain_com.crt
SSLCertificateKeyFile certs/www.somedomain.com/wwwsomedomaincom.key
SSLCertificateChainFile certs/www.somedomain.com/wwwsomedomaincom.crt
</VirtualHost>

Note that xampp comes with various folders for separately handling different types of certification files (ssl.crl, sss.crt, ssl.csr, ssl.key). We preferred to use a single folder, named ‘certs’ with per domain subfolders. You may want to keep using the xampp model.

Needless to say, you are expected to replace ‘somedomain’ with the real domain name for each hosted domain you wish to add to Apache as a virtual host for SSL. Repeat this step (adding a VirtualHost) for each domain.

Then in the ‘certs’ folder we added the certificates and key files into the subfolder for each domain.

That’s that easy. Nothing more to do. Just restart Apache.

One thing though, you may want to disable network-listener-2 in Glassfish to avoid connections though it’s listening port. This listener is generally set per default to listen for ports 81 or 8181.

Adding a VirtualHost record to Apache and pasting certification files into the subsequent folder is far more simple than adding a SSL certificate to Glassfish. And you can add as many records and certificates as you wish.