Move all SSL imports in helper functions.

The average user won't need the SSL features, so globally importing the
ssl module is costly. Also added nicer exc messages.