Added support for encrypted connections

Adds support for TLS encrypted connections