Implement secure connection, Fixes #2