A search for violation of the charge-parity CP symmetry in the D+→K−K+π+ decay is presented, with proton-proton collision data corresponding to an integrated luminosity of 5.4 fb−1, collected at a center-of-mass energy of 13 TeV with the LHCb detector. A novel model-independent technique is used to compare the D+ and D− phase-space distributions, with instrumental asymmetries subtracted using the Ds+→K−K+π+ decay as a control channel. The p-value for the hypothesis of CP conservation is 8.1%. The CP asymmetry observables ACP∣Sϕπ+=(0.95±0.43stat±0.26syst)×10−3 and ACP∣SK∗0K+=(−0.26±0.56stat±0.18syst)×10−3 are also measured. These results show no evidence of CP violation and represent the most sensitive search performed through the phase space of a multibody decay.