Assume the axes of the ellipse are aligned with the axes of the coordinate system. Then the ellipse satisfies
$$
\left(\frac{x-x_0}{a}\right)^2+\left(\frac{y-y_0}{b}\right)^2=1
$$
where $(x_0, y_0)$ is the center of the ellipse and $a$ and $b$ are the half-lengths of the ellipse axes.
Let $y=B$ and $x=R$ define the horizontal (Bottom) and vertical (Right) sides of the rectangle, respectively. Then the point $(x_0, B)$ lies on the ellipse. Substituting gives
$$
\left(\frac{B-y_0}{b}\right)^2=1
$$
or $b=B-y_0$. A similar substitution using the right side gives $a=R-x_0$. So the ellipse equation can be written
$$
\left(\frac{x-x_0}{R-x_0}\right)^2+\left(\frac{y-y_0}{B-y_0}\right)^2=1
$$
Rearranging this equation to solve for $B-y_0$
$$
B-y_0=\frac{B-y}{1\pm\sqrt{1-\left(\frac{x-x_0}{R-x_0}\right)^2}}
$$
The LHS of this is constant. If the two tangent points are given by $(x_1,y_1)$ and $(x_2,y_2)$ we can write
$$
B-y_0=\frac{B-y_1}{1\pm\sqrt{1-\left(\frac{x_1-x_0}{R-x_0}\right)^2}}=\frac{B-y_2}{1\pm\sqrt{1-\left(\frac{x_2-x_0}{R-x_0}\right)^2}}
$$
Since $B$, $R$, $(x_1,y_1)$ and $(x_2,y_2)$ are given, the only unknown is $x_0$. After solving (numerically) for $x_0$, $y_0$, $a$ and $b$ can be determined by back-substitution.
Hope that helps