Detect invalid certificates and create new ones