Added ability to configure a different SocketFactory for Https.

Kevin need you to cast your eye over this and make sure you are happy with this solution.
A test wouldn't hurt too.

I also want to get Diego to test it.