Enhanced the detection of secure connection.