Fix in secure socket detection logic