Current behaviour:
Currently the SSLChecker plugin is accepting allowedFingerprints as a string
Expected behaviour:
As per the Plugin Native implementation it will accept JSONArray. I will paste the below code for your reference. Please refer the highlighted code section below
Steps to reproduce:
Please refer the highlighted line
Related code:
public boolean execute(final String action, final JSONArray args, final CallbackContext callbackContext) throws JSONException {
if (ACTION_CHECKEVENT.equals(action)) {
cordova.getThreadPool().execute(new Runnable() {
public void run() {
try {
final String serverURL = args.getString(0);
**final JSONArray allowedFingerprints = args.getJSONArray(2);_**
final String serverCertFingerprint = getFingerprint(serverURL);
for (int j=0; j<allowedFingerprints.length(); j++) {
if (allowedFingerprints.get(j).toString().equalsIgnoreCase(serverCertFingerprint)) {
callbackContext.success("CONNECTION_SECURE");
return;
}
}
callbackContext.error("CONNECTION_NOT_SECURE");
} catch (Exception e) {
callbackContext.error("CONNECTION_FAILED");
//callbackContext.error("CONNECTION_FAILED. Details: " + e.getMessage());
}
}
});
return true;
} else {
callbackContext.error("sslCertificateChecker." + action + " is not a supported function. Did you mean '" + ACTION_CHECK_EVENT + "'?");
return false;
}
}
I'm submitting a ... (check one with "x")
Current behaviour: Currently the SSLChecker plugin is accepting allowedFingerprints as a string
Expected behaviour: As per the Plugin Native implementation it will accept JSONArray. I will paste the below code for your reference. Please refer the highlighted code section below
Steps to reproduce: Please refer the highlighted line
Related code: public boolean execute(final String action, final JSONArray args, final CallbackContext callbackContext) throws JSONException { if (ACTION_CHECKEVENT.equals(action)) { cordova.getThreadPool().execute(new Runnable() { public void run() { try { final String serverURL = args.getString(0); **
final JSONArray allowedFingerprints = args.getJSONArray(2);
_** final String serverCertFingerprint = getFingerprint(serverURL); for (int j=0; j<allowedFingerprints.length(); j++) { if (allowedFingerprints.get(j).toString().equalsIgnoreCase(serverCertFingerprint)) { callbackContext.success("CONNECTION_SECURE"); return; } } callbackContext.error("CONNECTION_NOT_SECURE"); } catch (Exception e) { callbackContext.error("CONNECTION_FAILED"); //callbackContext.error("CONNECTION_FAILED. Details: " + e.getMessage()); } } }); return true; } else { callbackContext.error("sslCertificateChecker." + action + " is not a supported function. Did you mean '" + ACTION_CHECK_EVENT + "'?"); return false; } }Other information: https://github.com/EddyVerbruggen/SSLCertificateChecker-PhoneGap-Plugin/blob/master/src/android/nl/xservices/plugins/SSLCertificateChecker.java