5. In a cube with edge length $a$, there is an inscribed sphere. A line is drawn through the midpoints of two edges that are skew lines of the cube. The length of the segment of this line that is intercepted by the sphere is ( ).
A. $(\sqrt{2}-1) a$
B. $\frac{\sqrt{2}}{2} a$
C. $\frac{1}{4} a$
D. $\frac{1}{2} a$
5. B

As shown in the figure, it is easy to prove: $P N \perp M N$ ( $P$ is the midpoint). By symmetry, we know $O G=\frac{1}{2} P N=\frac{\sqrt{2}}{4} a$, so $E F=2 E G=$ $2 \sqrt{\left(\frac{1}{2} a\right)^{2}-\left(\frac{\sqrt{2}}{4} a\right)^{2}}=\frac{\sqrt{2}}{2} a$.