0

I am trying to create extension for bypassing server authentication, install it on Firefox browser and pass the .xpi file while driver creation so that it gets invoked while login and the server authentication is bypassed. Facing error while installing the .xpi file on firefox. Error: "This add on could not be installed because it appears to be corrupt"

Steps 1. Created a manifest.json file (Code mentioned below)

{
“name”: “Webrequest API”,
“version”: “1.0”,
“description”: “Extension to handle Authentication window”,
“permissions”: [
“webRequest”,
“webRequestBlocking”,
“”
],
“background”: {
“scripts”: [“webrequest.js”]
},
“manifest_version”: 2
}
  1. Created webrequest.js file. Code mentioned below.

    var target = “https://sso.viacomcloud.com/”;

    var myCredentials = {
    username: “getestone”,
    password: “V*******”
    }
    
    var pendingRequests = [];
    
    // A request has completed.
    // We can stop worrying about it.
    function completed(requestDetails) {
    console.log(“completed: ” + requestDetails.requestId);
    var index = pendingRequests.indexOf(requestDetails.requestId);
    if (index > -1) {
    pendingRequests.splice(index, 1);
    }
    }
    
    function provideCredentialsSync(requestDetails) {
    // If we have seen this request before, then
    // assume our credentials were bad, and give up.
    if (pendingRequests.indexOf(requestDetails.requestId) != -1) {
    console.log(“bad credentials for: ” + requestDetails.requestId);
    return {cancel:true};
    }
    pendingRequests.push(requestDetails.requestId);
    console.log(“providing credentials for: ” + requestDetails.requestId);
    return {authCredentials: myCredentials};
    }
    
    browser.webRequest.onAuthRequired.addListener(
    provideCredentialsSync,
    {urls: [target]},
    [“blocking”]
    );
    
    browser.webRequest.onCompleted.addListener(
    completed,
    {urls: [target]}
    );
    
  2. Created a zip file using 7-zip file manager and renamed the zip file as Ext.xpi

  3. Opened about:config on firefox (verson 70) and changed xpiextensionsignrequired to ‘False’

  4. Opened about:addons on firefox. Selected ‘install extension from a file’. Select the Ext.xpi created in step 4 above.

  5. I get the following error: ” this add on could not be installed because it appears to be corrupt.” instead of getting the Install option on Firefox browser.

Please help @SubjectiveReality

SJN
  • 377
  • 2
  • 8
  • 18
  • To pass server authentication can be achieved very easier way. Using Firefox profile manager create new browser profile. Start Firefox with this new profile. Go to the page, proceed the server authentication manualy and save your credentials. Using code from https://stackoverflow.com/questions/58609201/firefox-profile-unable-to-automatically-download-file/58622913#58622913 load your test with existing browser profile with saved credentials. This way you can baypass even certificate authentication with imported certificate file and setting 'use always one certificate' in Firefox options. – pburgr Nov 21 '19 at 16:23
  • can you give the correct manifest.json and webreques.js files? – Shashank Shekhar Nov 23 '19 at 13:02

1 Answers1

0

Try using the class "Robot" and send keys in case you are looking for a quick solution.

Robot rb= new Robot(); rb.Keypress().....

Asjad Azeez
  • 53
  • 13
  • Welcome to Stackoverflow! I think this may not be a clear solution. Please ensure that you use comments to share information which does not provide a definitive solution to the question. This helps maintain the quality on SO. If you don't have enough reputation, don't worry, you'll earn it in time! Also, we generally expect some explanation as to why the solution would work if it does, so that the OP can learn from it. Perhaps edit your answer to include that? – Aman Dec 29 '20 at 13:28