The modeling of the probability of joint default or total number of defaults among the firms is one of the crucial problems to mitigate the credit risk since the default correlations significantly affect the portfolio loss distribution and hence play a significant role in allocating capital for solvency purposes. In this article, we derive a closed-form expression for the probability of default of a single firm and the probability of the total number of defaults by any time t in a homogeneous portfolio of firms. We use a contagion process to model the arrival of credit events that causes the default and develop a framework that allows firms to have resistance against default unlike the standard intensity-based models. We assume the point process driving the credit events to be composed of a systematic and an idiosyncratic component, whose intensities are independently specified by a mean-reverting affine jump-diffusion process with self-exciting jumps. The proposed framework is competent of capturing the feedback effect, an empirically observed phenomenon in the default events. We further demonstrate how the proposed framework can be used to price synthetic collateralized debt obligation (CDO) and obtain a closed-form solution for tranche spread. Finally, we present the sensitivity analysis to demonstrate the effect of different parameters governing the contagion effect on the spread of tranches and the expected loss of the CDO.