In my application, I am using HttpClient for making a service call. During the security testing, I am requested to implement the SSL Pinning. I got the information and put the certificate on the www/certificate folder too. But have a doubt about
if I implement the code in app.component.ts only enough or all service calling place should I implement
It makes no sense to wrap an async call in try catch unless you’re using async/await. Besides that what you have should work if you are running it on app startup (like in app.component.ts constructor platform.ready call). Make sure you don’t do any startup http calls before doing this though.
Also you can no longer use httpClient, you instead need to use the http native plugin to make your calls now, that’s kind of the whole point of what you’re doing. Only native code can use certificate pinning, so you have to use that.
As far as testing, just set up a proxy and your http calls should fail. This one is generally recommended: https://mitmproxy.org/