Updated to use SSL (https) connection if detected.