raise SSLHandshakeError if SSL handshake fails
fix SSL exception
move SSLSocket.do_handshake() to wrapper function