I have found 2 solution for achieving the above one 1] for ANDROID
Pining SHA-256 Public key in network_security_confile.xml file
<?xml version="1.0" encoding="utf-8"?>
<network-security-config>
<domain-config cleartextTrafficPermitted="false">
<domain includeSubdomains="true">yourserver.com</domain>
<pin-set expiration="2025-01-01">
<pin digest="SHA-256">HYrCjnv1DYq5Fjy3cgMScHZbpFMKoLQaUBQ39fxztmE=</pin>
</pin-set>
</domain-config>
</network-security-config>
2]for IOS Plugin: $ ionic cordova plugin add cordova-plugin-advanced-http $ npm install --save @ionic-native/http@4 after installing and importing they have mentioned that pin the certificate for ios like this
**step:1 ** 1]Importing that http in my app.module.ts file adding http in my provider a]import { HTTP } from '@ionic-native/http'
b] providers: [
StatusBar,
SplashScreen,
HTTP,
{ provide: ErrorHandler, useClass: IonicErrorHandler }
]
2]Place your .cer files in the www/certificates directory of your Ionic project.
step:2
constructor(private http: HTTP, private platform: Platform) {
this.platform.ready().then(() => {
if (this.platform.is('cordova')) {
// Enable SSL pinning
this.http.setServerTrustMode('pinned');
this.http.setPinningMode('default');
}
});
}
SSL PINNING for IOS After adding that code snippet I am getting error like when I hover on setServerTrustMode and setPinningMode. Property 'setServerTrustMode' does not exist on type 'HTTP' and Property 'setPinningMode' does not exist on type 'HTTP'
currently it is not working , If there any other sufficient method is there please let me know that....