Fix handling of certificate

Keep the original length of the entries, since we're popping elements off. Otherwise signing fails.