Here’s the catechism on it:
Legitimate defense
2263 The legitimate defense of persons and societies is not an exception to the prohibition against the murder of the innocent that constitutes intentional killing. “The act of self-defense can have a double effect: the preservation of one’s own life; and the killing of the aggressor. . . . The one is intended, the other is not.”65
2264 Love toward oneself remains a fundamental principle of morality. Therefore it is legitimate to insist on respect for one’s own right to life. Someone who defends his life is not guilty of murder even if he is forced to deal his aggressor a lethal blow:
If a man in self-defense uses more than necessary violence, it will be unlawful: whereas if he repels force with moderation, his defense will be lawful. . . . Nor is it necessary for salvation that a man omit the act of moderate self-defense to avoid killing the other man, since one is bound to take more care of one’s own life than of another’s.
Add to that the passage in the gospel in which Jesus advises his disciples to sell an extra cloak and buy a sword for their travels. Also, the 144th psalm which begins “Blessed be the Lord my rock, who teacheth my hands to war and my fingers to fight”.
CC
“Those who beat their swords into plowshares will plow for those who didn’t”
I seem to recall Jesus instructing that the time is at hand to sell the cloak and buy the sword.