An ambitious climate policy can trigger tensions in societies with low trust and deep social divisions. We examine public preferences for policies to achieve energy security and climate change mitigation goals in the context of the energy crisis caused by Russia's invasion of Ukraine. We conducted a discrete choice experiment, using a willingness-to-pay approach, on a representative sample of 10,000 people in Poland, a country heavily reliant on fossil fuels in transport and domestic heating. We found a strong aversion to a carbon tax among citizens, which is only slightly mitigated by redistribution policies. Income and age shape preferences for climate and energy policies. People with lower incomes (bottom quartile) place lower value on achieving climate change mitigation (15%) and energy security (10%) goals than the general population (17% and 14% willingness to pay, respectively). Younger individuals (aged 18-34) are willing to forego a greater share of their income to mitigate climate change than those aged 55 or older (28% vs. 12%) but a lower share (11% vs. 16%) to reduce fuel imports from Russia. Finally, we quantify the heterogeneity of preferences regarding redistribution measures and evaluate their efficiency. Households with low incomes prefer cash transfers as a redistribution measure, while people with high incomes prefer subsidies for green technology investments. Given the strong aversion of people with low incomes to a carbon tax, policymakers should prioritise efficient redistribution measures for them.