Allah, the Blessed and Exalted, says: "then the freeing of a neck (slave) before they touch one another; and whoever does not find (a slave), then fasting for two consecutive months before they touch one another" [Surah al-Mujadilah: 3-4].
Hadith Referenceالسنن الكبرى للبيهقي / كتاب الظهار / Q15274