added tls support

closes issue 1