Updated certificate structure check and error message