Botswana will host the first leg on the weekend of July 15/16, with the return in South Africa a week later.
If they advance past that stage they will face the winner of the tie between Swaziland and Zambia in September for a place in the continental finals.
The CHAN tournament is for home-based players only and the qualifiers are arranged regionally, with Southern Africa getting three slots.
South African reached the quarterfinals of the 2011 tournament in Sudan, but embarrassingly did not make it out of their first round pool when they hosted in 2014 despite a squad that boasted the best of Premier Soccer League talent.