Is there a method for verifying the application signature in Ionic?

For the past 2 days, I've been on a quest to find information about app certificate validation libraries/functions in Ionic. After discovering SignatureCheck.java for Android (link: enter link description here), I wonder if there is a similar solution implemented in TypeScript for checking if an app certificate matches or not. Any suggestions or guidance would be greatly appreciated. Thank you.

Answer №1

Just recently, I had a similar question and stumbled upon this insightful post: https://medium.com/@atifhussain.nu21/ssl-pinning-in-ionic-cordova-based-applications-ce993adcc07

It appears to offer a practical solution by utilizing the cordova plugin/library 'cordova-plugin-sslcertificatechecker'.

Here is an example code snippet for reference:

import { Injectable, Injector } from '@angular/core';
import {
 HttpEvent,
 HttpHandler,
 HttpInterceptor,
 HttpRequest
} from '@angular/common/http';
import { Network } from '@ionic-native/network';
import { Observable } from 'rxjs/Rx';
import { CONFIG_CONSTANTS } from '../../common/constant/app-config';
import { MESSAGE_CONSTANTS } from '../../common/constant/message';
declare var window: any;
@Injectable()
export class RequestInterceptor implements HttpInterceptor {
 helperFunction: HelperFunctions;
constructor(private network: Network, private injector: Injector) { }
intercept(request: HttpRequest<any>, next: HttpHandler): Observable<HttpEvent<any>> {
this.helperFunction = this.injector.get(HelperFunctions);
let setHeader = {
   'ContentType': 'application/json',
   'Accept': 'application/json',
   'DEVICETYPE': 'MOBILE',
   'X-Requested-With': 'XMLHttpRequest',
   'Content-Type': 'application/json',
   'dataType': 'json'
  };
let Host = CONFIG_CONSTANTS.BASE_URL;
if (this.network.type === 'none') {
   this.helperFunction.showAlert(MESSAGE_CONSTANTS.CONNECTION_NOT_WORKING);
   return next.handle(request);
  }
return this.checkSecurity(`${Host}${request.url}`, request).flatMap((modifiedReq) => {
   let newReq = null;
   if (modifiedReq['message'] === 'CONNECTION_SECURE') {
    newReq = request.clone({
     url: `${Host}${request.url}`,
     setHeaders: setHeader
    });
   }
   return next.handle(newReq);
  });
 }
checkSecurity(URL, request) {
  return new Observable((observer) => {
   window.plugins.sslCertificateChecker.check(
    (message) => {
     return observer.next({req: request, message: message});
    },
    (message) => {
     return observer.error({req: request, message: message});
    },
    URL,
    CONFIG_CONSTANTS.FINGERPRINT);
  });
 }
}

I have yet to test this in my own project. Hopefully, this information proves useful. Feel free to share your experience! :)

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

What steps do I need to take to extract the date and month from a single datepicker using the code below?

<div class="col-md-3 pull-left" style="padding:9px"> <input type="text" id="datepicker" class="form-control"> </div> The HTML and C ...

I am experiencing an issue with React Select where it does not seem to recognize the value I have

Forgive me if this question sounds naive, I am still relatively new to Reactjs, I kindly ask not to suggest using Hooks as they are not compatible with my current project. Currently, I am focusing on a form and its validation process. Here is the snippe ...

What are the steps to update your profile picture using Angular?

In my Angular 6 application, I am implementing an image upload feature with the following code: Html: <img [src]="url ? url : 'https://www.w3schools.com/howto/img_avatar.png'"> <br/> <input type='file' (change)="onSelec ...

Preventing duplication of code execution in recycled PHP elements

Currently, I have implemented a generic toolbar that is used on multiple pages of my web application by using PHP include. This toolbar contains log in/log out functionality and checks the log in status upon loading to update its UI accordingly. Initially ...

Is there a way to mock a keycloak API call for testing purposes during local development?

At my company, we utilize Keycloak for authentication integrated with LDAP to fetch a user object filled with corporate data. However, while working remotely from home, the need to authenticate on our corporate server every time I reload the app has become ...

The (window).keyup() function fails to trigger after launching a video within an iframe

Here is a code snippet that I am using: $(window).keyup(function(event) { console.log('hello'); }); The above code works perfectly on the page. However, when I try to open a full view in a video iframe from the same page, the ke ...

What is the best way to provide transformers in ts-node?

Currently, I am in the process of creating my own compiler for Typescript because I require the usage of transformers. Within our workflow, we utilize ts-node to execute specific files (such as individual tests), and it is essential that these transformer ...

Expansive image coverage

My footer design includes a rounded left image, a repeating middle section, and a rounded right image. How can I ensure that it scales perfectly responsively without overlapping? Ideally, the solution would involve adjusting the width of the middle section ...

Why is the getElement().getProperty("value") function not functioning properly?

I am facing an issue with reading a property in my web component. I am puzzled as to why it is not working correctly. I created a simple example, and after clicking the button, I expect to retrieve the value of the property, but it returns null. I am unsur ...

AJAX list refresh, fetch additional items and tally

Looking for a solution to update the values of listUsernames and numUsernames after adding an item? Check out this scenario: <ul id='usernameList'> <li class='username'>John</li> <li class='username&apo ...

The conversion to ObjectId was unsuccessful for the user ID

I'm looking to develop a feature where every time a user creates a new thread post, it will be linked to the User model by adding the newly created thread's ID to the threads array of the user. However, I'm running into an issue when trying ...

Confirming user banking information is necessary solely for account activation through Stripe

I've been working with NodeJS and ExpressJS Is there a way to set up account verification with Stripe? I want to confirm that users have bank accounts without charging them. What kind of information can I access through this verification process? My ...

The Vue3 property 'x' is not recognized on type 'Function' as a global property

I have encountered a strange issue with my Quasar app. I am attempting to define a global variable that consists of metadata about the application in an object format. Despite successfully compiling the app and displaying the correct information on the HTM ...

Sending an ID from an array within a *ngFor loop to a different component in Angular: a step-by-step guide

I have a collection of items that I loop through using ngFor. My goal is to pass all its attributes to another component. I attempted to accomplish this with the following code: *ngFor='let item of postList [routerLink]="['/detailed-post&ap ...

Potential Issue: TypeScript appears to have a bug involving the typing of overridden methods called by inherited methods

I recently came across a puzzling situation: class A { public method1(x: string | string[]): string | string[] { return this.method2(x); } protected method2(x: string | string[]): string | string[] { return x; } } class B extends A { prot ...

Identifying a flaw in an HTML5 video

I am attempting to identify when an error occurs while playing an HTML5 video. Specifically, I am encountering a situation where I am trying to play an HLS video on a MAC (where "canPlayType" is at least "maybe"), but the video will not play for unknown r ...

A guide on converting JSON strings into arrays using Javascript

In my JavaScript program, I have a Mocha test that checks if all available currencies are displayed in a drop-down list: it('displays all available currencies in drop down list', () => { return invoiceEditPage.details.currencyDropDown.dr ...

Angular does not always interpret the value returned from a Promise.all call

One of the challenges I'm facing is related to the structure of my controller: controller.things = ['a', 'b', 'c']; controller.loading = true; controller.responses = []; controller.handlePromises = function(){ var pr ...

Monitoring Object Changes in Angular 4

ETA: I am aware of different methods for monitoring my form for alterations. However, that is not the focus of my inquiry. As indicated by the title, my question pertains to observing changes within an object. The application displayed below is solely for ...

Is there a more concise method to reference the parent scope in AngularJS in this scenario?

Is there a shorter way to reference the parent scope within this controller? $scope.tables = []; $scope.newTable = function(){ $scope.tables.push({name:"Table " + ($scope.tables.length+1),cols:[]}); $scope.selected = $scope.tables.length-1; }; I ...