Book Image

PhoneGap for Enterprise

By : Kerri Shotts
Book Image

PhoneGap for Enterprise

By: Kerri Shotts

Overview of this book

Table of Contents (16 chapters)
PhoneGap for Enterprise
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Ensuring secure communication


As we discussed in Chapter 3, Securing PhoneGap Apps, the best way to ensure that communication with the backend is secure is to use SSL Certificate pinning. Prior to every request, we verify that the certificate being utilized to secure communications is a known certificate.

We're using a plugin developed by Eddy Verbruggen called SSLCertificateChecker. To add this to a Cordova project, refer to Chapter 3, Securing Phonegap Apps, or the Getting Started section in this chapter.

We covered a very simple example in Chapter 3, Securing PhoneGap Apps. Unfortunately, that particular sample relied solely on callbacks, it would have been better if the sample was wrapped with a Promise instead, as in the following code:

  function _checkIfSecure( server, fingerprints ) {
    var deferred = Q.defer();
    try {
      var args = [];
      // success
      args.push( function success( message ) {
        deferred.resolve( message );
      } );
      // failure
      args...