2265 Legitimate defense can be not only a right but a grave duty for one who is responsible for the lives of others. The defense of the common good requires that an unjust aggressor be rendered unable to cause harm. For this reason, those who legitimately hold authority also have the right to use arms to repel aggressors against the civil community entrusted to their responsibility. The efforts of the state to curb the spread of behavior harmful to people's rights and to the basic rules of civil society correspond to the requirement of safeguarding the common good. Legitimate public authority has the right and duty to inflict punishment proportionate to the gravity of the offense.
Punishment has the primary aim of redressing the disorder introduced by the offense.
When it is willingly accepted by the guilty party, it assumes the value of expiation. The primary effect of punishment is to redress the disclosure caused by the offense. When his punishment is voluntarily accepted by the offender, it takes on the value of expiation. Moreover, punishment has the effect of preserving public order and the safety of persons. Assuming that the guilty party's identity and responsibility have been fully determined, the traditional teaching of the Church does not exclude recourse to the death penalty, if this is the only possible way of effectively defending human lives against the unjust aggressor.