Fix SSL handshake error to  be catchable

fixes #800