This paper develops a theory of optimal fertility behavior under mortality shocks. In an OLG model, young adults determine their optimal fertility, labor supply and life-cycle consumption with both exogenous child and adult mortality risks. We show that a rise in adult mortality exerts an ambiguous effect on both net and total fertility in a general equilibrium framework, while child mortality shocks unambiguously lead to a rise in total fertility, leaving net fertility unchanged. We complement our theory with an empirical analysis using a sample of 39 Sub-Saharan African (SSA) countries over the 1980-2004 period, examining the overall effects of the child and adult mortality channels on both total and net fertility. We find child mortality to exert a robust, positive impact on total fertility but no impact on net fertility, whereas a rise in adult mortality is found to negatively influence both total and net fertility. Given the particular demographic profile of the HIV/AIDS epidemic (killing essentially young, active adults), we then conclude in favor of an unambiguous negative effect of the HIV/AIDS epidemic on net fertility in SSA.