Sooner or later you will need to develop WebObjects applications that work with SSL requests over https protocol. If ssl is configured on your deployment server, you can probably just change http to https in the app entry URL and the app will probably just work over https protocol. However if your application requires security, you cannot just depend on your users typing in a URL that begins with https. Also since SSL encryption adds more load to the webserver, you may want decide that just some pages need to be returned securely over https and the rest returned via plain old http. In any case, you may want to or need to set up your local OS X development machine to support https protocol so that you can properly test your application. Note also that setting up ssl for testing can be a far simpler task (and not really secure) than setting up real authentic SSL certificates for use in a production server.


These instructions were written and tested on the following, but should work on any 10.5.X config or later

  • OS X Leopard Client 10.5.4
  • Standard built-in apache2
  • If you like record and verify your OS config as follows:
    • $ openssl version
      • OpenSSL 0.9.8g 19 Oct 2007
    • $ httpd -v
      • Server version: Apache/2.2.8 (Unix)


Development via Apache Webserver

By default, WebObjects development installations typically run via DirectConnect. For https development, we must run thru the apache webserver built in to every OS X machine. So before going any further, configure your WebObjects development environment so that your development application launches and runs thru apache using the host name "localhost".

Configuring Apache for https://localhost

Make the private key and SSL certificate

Normally creating SSL certificates for production use is quite involved, however since we are just doing localhost development and testing, we can bypass all the mumbo-jumbo and create the minimal unpassworded private key and SSL certificate the easy way. Do not use this method for creating production server SSL certificates!

Open terminal and follow the commands shown below in my transcript which is self-explanatory if you are familiar with Terminal...

mymac$ cd /etc/apache2/
mymac$ sudo -s

bash-3.2# mkdir devsslcerts
bash-3.2# cd devsslcerts/

Next run the one single openssl command that will make the two files we need in their final folder that we just created above.
Note you will be asked for a bunch of info for the certificate. Follow what I have done below. In particular, enter "localhost" in the Common Name field!

bash-3.2# openssl req -days 3650 -new -x509 -nodes -out localhost_server.crt -keyout localhost_server.key

Generating a 1024 bit RSA private key
writing new private key to 'localhost_server.key'
You are about to be asked to enter information that will be incorporated
into your certificate request.
What you are about to enter is what is called a Distinguished Name or a DN.
There are quite a few fields but you can leave some blank
For some fields there will be a default value,
If you enter '.', the field will be left blank.
Country Name (2 letter code) [AU]:US
State or Province Name (full name) [Some-State]:Florida
Locality Name (eg, city) []:Tampa
Organization Name (eg, company) [Internet Widgits Pty Ltd]:Five WebObjects Sailors, Inc.
Organizational Unit Name (eg, section) []:Software Engineering Department
Common Name (eg, YOUR name) []:localhost
Email Address []

bash-3.2# ls -al
total 16
drwxr-xr-x   4 root  wheel   136 Jul 21 16:58 .
drwxr-xr-x  10 root  wheel   340 Jul 21 16:56 ..
-rw-r--r--   1 root  wheel  1497 Jul 21 16:58 localhost_server.crt
-rw-r--r--   1 root  wheel   887 Jul 21 16:58 localhost_server.key

Configure Apache2 to Use Your Development Certificates for localhost

Using your favorite command line editor, edit the apache config file at
making the changes shown in the following 2 screenshots:

Setting Apache server name to localhost

Including SSL Configuration file into main Apache config file

Next edit the ssl config file itself at
making the changes shown in the following sceenshot:

Setting up the SSL Config file

Restart apache

bash-3.2# apachectl graceful



Right at this point I got the error:

ulimit: open files: cannot modify limit: Invalid arg

After a quick google search I found this which seems to have fixed the error:

Also, for my https://... links my rewrite rules in apache weren't getting fired.  To get them to work I had to add them to the httpd-ssl.conf file just below the General setup stuff shown in the figure above.  I just copied them from my httpd.conf file and pasted them in.  Not sure if this is the best way to handle it, but it's working for me on my development machine at least.


Finally, verify that https is working:

Verify https://localhost is working

Detecting SSL

Code for detecting whether SSL is active for the current request:
I'm told this won't work with IIS:

// Is this page being accessed securely?
boolean secureMode = false;
String header = context.request().headerForKey("https");
if( header == null ) {
  log.debug( "no https header, looking for server_port" );
  header = context.request().headerForKey( "server_port" );
  if( header == null ) {
    log.debug( "no server_port header found, assuming insecure connection" );
  } else {
    log.debug( "server_port header found, using it" );
    secureMode = header.equals( "443" );
} else {
  log.debug( "https header found, using it" );
  secureMode = header.equals( "on" );
log.debug( "secure mode set to " + secureMode );

Using SSL in DirectConnect

Mike Schrag said in early 2011 that it was possible to use SSL in DirectConnect, that is was simply hidden. A property was added to enable it, and instructions added to the Properties file of ERExtensions. This is the part from the Properties file:

## You should probably not enable any of these settings in a normal Apache webserver deployment,
## in particular the ssl port property, as this is used by ERX to generate https URLs, which must
## match your Apache config.
## To enable SSL support with DirectConnect, you must do the following:
## * In your Resources folder, run "keytool -genkey -alias WebObjects -keyalg RSA -keystore adaptorssl.key".  Select a 
##   password for your keystore (i.e. "changeit"), and set the "your first name and last name" field to match the hostname 
##   that you will be running your directconnect app off of.
## * In your Resources folder, create an executable script (it MUST BE EXECUTABLE) named "adaptorsslpassphrase" with the
##   contents:
##   echo changeit
##   where you should replace "changeit" for whatever password you selected in the previous step.
## * Set the following property to true

## (optional) To specify an SSL host name other than what is returned from a call to
##, you can override it below

## (optional) To select an SSL port other than 443, uncomment the following. If you are already running Apache with SSL,
## you probably want to set this.  If the port number is 0, the SSL port will be automatically assigned (using the same
## mechanism that WO uses to set the regular port)