Ported HTTPS from atronix / saphirion