IONIC 4 SSL Pinning issue only in iOS

44 Views Asked by At

I'm currently using ionic-native-http and cordova-plugin-advanced-http for SSL Pinning in my Ionic 4 project.

For SSL Certificate, I'm using the certificate in Google.com

For the platform Android everything works as expected.

On the other hand in iOS the code throws an error in runtime and does not work as expected.

The error:

NSLocalizedDescription=The certificate for this server is invalid. You might be connecting to a server that is pretending to be “www.google.com.tr” which could put your confidential information at risk.

Here is my certificate folder location. The top certificate is the result of build operation in ionic:

enter image description here

For testing ssl pinning in my app.component.ts file here is the code block that throws and error:

this.http
        .setSSLCertMode("pinned")
        .then((response) => {
          console.log("SSL Pinning - Aktif GÖrünüyor");
        })
        .catch(() => {
          console.log("SSL Pinning - Başarısız");
        });
      this.http
        .get("https://www.google.com/", {}, {})
        .catch((error) => {
          const showMaintenanceMessage = this.modalController.create(
            Maintenance,
            {
              message: "Sertifikanız Doğrulanamadı",
            },
            {
              showBackdrop: false,
              enableBackdropDismiss: false,
            }
          );
          showMaintenanceMessage.present();

          this.platform.exitApp();
        });
      // SSL PINNING END //

I stuck at the step for a month and eager to find a solution with respect to lack of library assistance.

Thanks in advance.

0

There are 0 best solutions below