checking for a valid certificate