CCC 1584 Since it is ultimately Christ who acts and effects salvation through the ordained minister, the unworthiness of the latter does not prevent Christ from acting.1 St. Augustine states this forcefully:
As for the proud minister, he is to be ranked with the devil. Christ’s gift is not thereby profaned: what flows through him keeps its purity, and what passes through him remains dear and reaches the fertile earth. .. The spiritual power of the sacrament is indeed comparable to light: those to be enlightened receive it in its purity, and if it should pass through defiled beings, it is not itself defiled.2
1 Cf. Council of Trent: DS 1612; DS 1154.
2 St. Augustine, In Jo. ev. 5,15:PL 35,1422.