Refactor SSL check