Implement HTTPS support. Fixes #45