We are working on a mobile app that communicates with the backend through REST API over SSL. Mobile device executes cert validation on the API call (using standard libraries in mobile frameworks). If we try to connect the mobile device through proxy (such as Charles), we see all the traffic, but it is encrypted - as expected. However, if I enable SSL proxy, generate root certificate and install that cert on my device, I will see all the data in clear text through Charles - again, as expected.
The question is, how to prevent this? The main target, of course, is to expose data ONLY if device calls allowed server with a valid certificate for that server.