The theory of an X-ray Fabry-Perot interferometer (FPI) is developed as a particular case of the dynamical theory of X-ray Bragg diffraction in layered crystalline systems. Mathematical expressions are derived for the transmissivity and reflectivity of the X-ray FPI built as a system of two perfect crystal plates parallel to each other. The performance of the X-ray FPI is similar to that of the optical FPI. Both show fine interference structure in the transmission and reflection dependences. However, for the X-ray FPI this occurs only inside the region of the Bragg back diffraction peak. The influence of possible imperfections, such as the roughness of the crystal plate surfaces and the error in the parallelism of the atomic planes are discussed. It is shown that both factors may significantly deteriorate the performance of the X-ray FPI. Numerical estimations are given.