cordova-plugin-pinnedhttps
A phonegap plugin that will allow you to make HTTPS requests with certificate fingerprint verification
Installation
phonegap plugin add cordova-plugin-pinnedhttps
Usage
This plugin compiles and has been tested as part of an other project (a cordova app).
NOTE: This plugin doesn't follow HTTP redirections
var https = new navigator.httpsBuilder(fingerprints);
https.get('https://yoursite.tld/yourpath', function(err, res){
if (err){
if (err == 'INVALID_CERT'){
} else {
}
} else {
res.statusCode
res.headers
res.body
}
});
var reqOptions = {method:'post', host:'yoursite.tld', path: '/yourpath', [port: 443], [headers: {header1: 'value1', header2: 'value2'}], [body: {}]};
https.request(reqOptions, function(err, res){
if (err){
if (err == 'INVALID_CERT'){
} else {
}
} else {
res.statusCode
res.headers
res.body
}
});
NOTE : With https.request
, if returnBuffer
is defined in the reqOptions
, then res.body
will be returned as an Uint8Array
List of error messages
Error message | Meaning |
---|
INVALID_PARAMS | Invalid parameters |
INVALID_URL | Invalid URL |
INVALID_METHOD | Invalid HTTP method |
INVALID_HEADERS | Invalid options.headers parameter |
INVALID_BODY | Invalid options.body parameter |
INVALID_CERT | Invalid certificate found on server |
CANT_CONNECT | Can't connect to the server |
TIMEOUT | Connection timeout |
INTERNAL_ERROR | Internal error |
Testing
- Create a Cordova/Phonegap application
- Add the iOS and/or the Android platforms
- Add the testing framework and bind its page as the main page of the app
- Add this plugin
- Add this plugin's test cases, by adding the plugin located in the
tests
folder
cordova plugin add https://github.com/LockateMe/cordova-plugin-pinnedhttps.git#:/tests
License
This plugin is distributed under the terms of the MIT license.