refactor ssl cert checking a bit