Warner Technology Consulting Logo

Java Wrapper for OpenSSL

What is it?
This wrapper allows you to use the OpenSSL libraries from Java. The wrapper was originally written by Jonathan Tew and ported to Unix, specifically MOSXS, by me, for use in a tutorial found elsewhere on this site. It should work for other Unix platforms, although I haven’t had a chance to test it. This software was originally placed in the Public Domain by Jonathan Tew, and my modifications are contributed freely back into the Internet. Note that the MOSXS uses Java 1.1.x, so you are not required to have JDK1.2 installed, as all the other free solutions of which I am aware require. There is no warranty, no guarantee regarding any of this software. However, if you make modifications, I am willing to post them here for others to use. Specifically, if someone wants to undertake making the changes to the code so that it complies with the latest JSSE APIs, that would be a top priority; the current setup uses a non-standard API for tunneling.

What you’ll need
1. OpenSSL
To make use of the wrapper, you’ll need to get OpenSSL, compile it, and install it. Since Mac OS X Server isn’t one of the recognized systems, you’ll need to modify the Configure file. Add a line that looks like the one below, around line number 220. Please note that adding a compiler optimization flag (-O, -O2, or -O3) will cause the library to fail its tests. I don’ t know the reason, but I suspect the older version of gcc included with MOSXS.


"rhapsody", "cc:-DB_ENDIAN -DTERMIOS -fomit-frame-pointer -Wall:<libc.h>:(unknown)::
BN_LLONG DES_RISC1:::",

Be sure to include that comma at the end and enter the line above as one continuous line (no hard return). When you've entered that, type


./Configure rhapsody; make; make test

It takes a while to compile; on my 8500/180 it takes what seems like about an hour. If all goes well, you should get no fatal errors after make test. If you’ve made it this far, then you need to do a


make install
ln -s /usr/local/ssl/include/openssl /usr/include/openssl
ln -s /usr/local/ssl/lib/libcrypto.a /usr/lib/libcrypto.a
ln -s /usr/local/ssl/lib/libssl.a /usr/lib/libssl.a

either as root or using sudo. The last three lines create symbolic links so that other applications have half a chance of ever finding the include files and libraries.

2. C++ Wrapper Code
Part of the wrapper for the OpenSSL library is written in C++ and acts as an intermediary between the OpenSSL libraries and the Java portion of the wrapper. Under MOSXS, the easiest way to compile this was to use the Project Builder. For other Unix users, you can use this same file, but you'll probably need to ignore the makefile. Under MOSXS, the resulting libraries, libSSLSocket.A.dylib and libSSLSocket.dylib both need to be placed in /usr/lib/java/. I've tarred the project directory (152KB) for ease of use; it contains the compile libraries as well as the C++ code. Download it, modify it, or just copy the libraries as you wish.

3. Java Classes
These particular files provide the interface and Java portion of the wrapper. Java classes can be placed in a few different places under MOSXS. Perhaps the easiest place to put them is in /System/Library/Java/, although they can also go into ~/Library/Java/. Download them here (5KB).

How to put it together
Once you’ve installed the three pieces, you’re ready to test it out. You can use this sample HelloWorld.java file. You will need to modify the settings in the file since it is setup to run through my proxy server. There should be sufficient comments included for you to do this. This package also works with Ronald Tschalär’s free HTTPClient, although the wrapper needs to be modified so that HTTPClient can work with proxies. The modified HTTPConnection.java file that allows HTTPClient to work with this wrapper (again, no proxy support yet) can also be found here in a gzip format.



Back to the Warner Technology Home Page

Page created by: matt@warnertechnology.com

PGP Encryption Available for secured messages. Public key is available at MIT's site or here.

Business Text
Automotive Text
Computers Text
Site Search
Made with Macintosh!
Site by Warner Technology Consulting. All material is copyright 1999. If you reference material on this site, you are expected to annotate the source from which it came. That is, you may use information on this site, but you must clearly state from where you obtained it.
Page last updated on Thu, Dec 23, 1999

Text Links: BusinessAutomotiveComputerSGI
Mac OS X ServerMacintosh • Matt's Hack TV
Software • PS on Non-PS Printers • Porsche

R E A D E R • C O M M E N T S
Add a Comment