exception handling for TLS wrapping, added option to disable TLS