The resonant structure of the doubly Cabibbo-suppressed decay $D^+ to K^-K^+K^+$ is studied for the first time. The measurement is based on a sample of pp-collision data, collected at a centre-of-mass energy of 8 TeV with the LHCb detector and corresponding to an integrated luminosity of 2 fb$^-1$. The amplitude analysis of this decay is performed with the isobar model and a phenomenological model based on an effective chiral Lagrangian. In both models the S-wave component in the $K^-K^+$ system is dominant, with a small contribution of the $phi(1020)$ meson and a negligible contribution from tensor resonances. The $K^-K^+$ scattering amplitudes for the considered combinations of spin (0,1) and isospin (0,1) of the two-body system are obtained from the Dalitz plot fit with the phenomenological decay amplitude.