Ensure clean build

Hi,
These are some minor changes made after I pulled this repo to ensure that I had a clean build.

The main changes are to resolve compiler warnings regarding resource leaks.
The JDK I was using (1.7u45) didn't like the direct use of the X509Provider, so I changed this to use Bouncy Castle (actually I copied the code from WebScarab and integrated it).