[backport] Fix wrong handing integrity error on register or accept invitation.