SSL suport, take 3

Cleaned up version of the patch from #45.