Problem: Let $\mathfrak{g}$ be an orthogonal Lie algebra (type $B_l$ or $D_l$). If $Y$ is an orthogonal matrix, that is, $Y$ is invertible such that $Y^TSY = S$, prove that the function $X\mapsto YXY^{-1}$ is an automorphism of $ \mathfrak{g}$.
Attempt: Let the function:
$$\begin{align*} \varphi:\mathfrak{g}&\longrightarrow\mathfrak{g} \\[0.5em] X&\longmapsto YXY^{-1} \end{align*}$$
Let's see that $\varphi$ is an automorphism of $\mathfrak{g}$, that is, $\varphi$ is a homomorphism of $\mathfrak{g}$ to $\mathfrak{g}$.
Let $X_1,X_2\in\mathfrak{g}$, then:
$$\begin{align*} \varphi([X_1,X_2]) &= Y[X_1,X_2]Y^{-1} \\[0.5em] &= Y(X_1X_2 - X_2X_1)Y^{-1} \\[0.5em] &= Y(X_1X_2)Y^{-1} - Y(X_2X_1)Y^{-1} \\[0.5em] &= (YX_1Y^{-1})(YX_2Y^{-1}) - (YX_2Y^{-1})(YX_1Y^{-1}) \\[0.5em] &= \varphi(X_1)\varphi(X_2) - \varphi(X_2)\varphi(X_1) \\[0.5em] &= [\varphi(X_1),\varphi(X_2)] \end{align*}$$
So $\varphi$ is an automorphism of $\mathfrak{g}$. $\blacksquare$
Question: Is this proof correct? I think I'm missing something about the properties of $\varphi$ because I didn't use the hypothesis ($Y$ is invertible such that $Y^TSY = S$). I think I actually used it in the proof but I don't know where specifically. If the proof is correct I want to make it more rigorous.