The hint.Let $h$ be an altitude of the prism. Thus, $$\left(\frac{\sqrt{d_1^2-h^2}}{2}\right)^2+\left(\frac{\sqrt{d_2^2-h^2}}{2}\right)^2=a^2.$$