Reputation: 21
Iam new in Ionic 3 and i want to implement SSL pinning in my application. I am using this plugins https://ionicframework.com/docs/native/http/ and my home.ts looks like this
import { Component } from '@angular/core';
import { NavController } from 'ionic-angular';
import {HTTP} from '@ionic-native/http';
@Component({
selector: 'page-home',
templateUrl: 'home.html'
})
export class HomePage {
constructor(public navCtrl: NavController, public http:HTTP) {
}
ionViewDidLoad() {
this.load();
}
load(){
this.http.get('https://www.dashboard.mambowallet.com', {}, {})
.then(data => {
console.log("connection successful");
console.log(data.status);
console.log(data.data); // data received by server
console.log(data.headers);
})
.catch(error => {
console.log("connection not successful");
console.log(error.status);
console.log(error.error); // error message as string
console.log(error.headers);
});
}
}
And my app.modules.ts
looks like this
import { BrowserModule } from '@angular/platform-browser';
import { ErrorHandler, NgModule } from '@angular/core';
import { IonicApp, IonicErrorHandler, IonicModule } from 'ionic-angular';
import { SplashScreen } from '@ionic-native/splash-screen';
import { StatusBar } from '@ionic-native/status-bar';
import {HTTP} from '@ionic-native/http';
import { MyApp } from './app.component';
import { HomePage } from '../pages/home/home';
@NgModule({
declarations: [
MyApp,
HomePage
],
imports: [
BrowserModule,
IonicModule.forRoot(MyApp)
],
bootstrap: [IonicApp],
entryComponents: [
MyApp,
HomePage
],
providers: [
StatusBar,
SplashScreen,
HTTP,
{provide: ErrorHandler, useClass: IonicErrorHandler}
]
})
export class AppModule {}
I have saved the server SSL certificate at the src/assets folder and when i do ionic serve, on the browser the console outputs this
Am I missing something?
Upvotes: 2
Views: 1885
Reputation: 21
You need to test on a real device. You won't be able to use any cordova or native plugin within Chrome browser/emulator i.e. you cannot use "ionic serve"
Run this command below and use Safari to debug your app.
ionic cordova run ios --device -l --debug --verbose
Upvotes: 1