ssl.publickey.checker

7.0.0 • Public • Published

SSL PublicKey Checker

This plugin can be used to add an extra layer of security by preventing 'Man in the Middle' attacks

Installation

Latest stable version from npm:

$ cordova plugin add ssl.publickey.checker

Usage

First obtain the fingerprint of the SSL certificate of your server(s). You can find it f.i. by opening the server URL in Chrome. Then click the green certificate in front of the URL, click 'Connection', 'Certificate details', expand the details and scroll down to the SHA256 fingerprint.

var server = "yourdomainnamehere"; ex: npmjs.com
  var fingerprint = "C1 3D 53 79 Z2 YF 82 8E 1E BE FD DC 2D 7B 7D 24 31 1A 59 E1 0B 4B C8 04 6E 21 F6 FA A2 37 11 45";

  window.plugins.SSLPublicKeyChecker.check(
          successCallback,
          errorCallback,
          server,
          fingerprint);

   function successCallback(message) {
     alert(message);
     // Message is always: CONNECTION_SECURE.
     // Now do something with the trusted server.
   }

   function errorCallback(message) {
     alert(message);
     if (message === "CONNECTION_NOT_SECURE") {
       // There is likely a man in the middle attack going on, be careful!
     } else if (message.indexOf("CONNECTION_FAILED") >- 1) {
       // There was no connection (yet). Internet may be down. Try again (a few times) after a little timeout.
     }
   }
   

Need more than one fingerprint? In case your certificate is about to expire, you can add it already to your app, while still supporting the old certificate. Note you may want to force clients to update the app when the new certificate is activated.

 // an array of any number of fingerprints
var fingerprints = ["C1 3D 53 79 Z2 YF 82 8E 1E BE FD DC 2D 7B 7D 24 31 1A 59 E1 0B 4B C8 04 6E 21 F6 FA A2 37 11 45", "ZE ZO ZD", ..];

window.plugins.SSLPublicKeyChecker.check(
       successCallback,
       errorCallback,
       server,
       fingerprints);

Note:

If you have any questions/feedback, please reach out: venkatschinthakindi11@gmail.com

Package Sidebar

Install

npm i ssl.publickey.checker

Weekly Downloads

2

Version

7.0.0

License

MIT

Unpacked Size

17.8 kB

Total Files

8

Last publish

Collaborators

  • venkatschinthakindi11