Handle TLS exceptions. Fixes #5