Add option for secure connection

I added a secure option that, when set to true, will use the tls module for communication.

I put this pull request up to give people a chance to comment before it is merged into master. I'll merge in a couple of days if there are no issues.