Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Document how to disable XPI signing in Firefox 49+ #183

Open
alphapapa opened this issue Oct 1, 2016 · 32 comments
Open

Document how to disable XPI signing in Firefox 49+ #183

alphapapa opened this issue Oct 1, 2016 · 32 comments

Comments

@alphapapa
Copy link
Contributor

alphapapa commented Oct 1, 2016

Note: Definitive info from this issue is being added to this wiki page.

I just built Firefox 49 on Ubuntu 14.04 Trusty, switching from Gtk3 back to Gtk2 (because there's no Gtk3 version of my Gtk2 theme, QtCurve). Firefox 48 allowed me to install the Pentadactyl XPI I packaged, but Firefox 49 did not. sigh

A bit of googling around led me to this: http://www.ghacks.net/2016/08/14/override-firefox-add-on-signing-requirement/ I followed the instructions, restarted Firefox, and it worked, enabling me to install unsigned XPI extensions without rebuilding Firefox.

I think this should be documented somewhere prominently, as it saves a lot of trouble compared to rebuilding Firefox (until Mozilla kills this avenue, of course...). For posterity, here is a simple version of the instructions for Linux:

  • Create file /usr/lib/firefox/config.js with the following content:
try {
    Components.utils.import("resource://gre/modules/addons/XPIProvider.jsm", {})
        .eval("SIGNED_TYPES.clear()");
}
catch(ex) {}
  • Create file /usr/lib/firefox/defaults/pref/config-prefs.js with the following content:
pref("general.config.obscure_value", 0);
pref("general.config.filename", "config.js");
  • Restart Firefox.

Now you should be able to install unsigned extensions.

If (when?) Mozilla "plugs" this "hole", it should be possible to rebuild Firefox to disable extension signing by doing this:

  • Download and extract the Firefox source (e.g. on Debian/Ubuntu, apt-get source firefox)..
  • Open the file toolkit/mozapps/extensions/internal/XPIProvider.jsm.
  • Find this code:
const SIGNED_TYPES = new Set([
      "webextension",
      "extension",
      "experiment",
  ]);
  • Remove extension and webextension from the set.
  • Build and install Firefox (out of scope for these instructions).
@alphapapa
Copy link
Contributor Author

BTW, I tried to post this to the Pentadactyl Google Group, but all I get is, "You do not have permission to access this content. (#554)" I recall getting similar errors when trying to post to the group in the past, a year or two ago. Google Groups appears to be completely useless; we should really move discussion elsewhere.

@Thiel
Copy link

Thiel commented Oct 1, 2016

Hi,

First thing first, thanks ^^.

For MacOs, the file seems to be placed in
/Applications/Firefox.app/Contents/Resources/pref.js
/Applications/Firefox.app/Contents/Resources/defaults/pref/config-pref.js

But then I get the error message when I try to install pentadactyl: "Pentadactyl could not be installed because it is not compatible with Firefox 49.0.1.

Did you get the same issue ?

@alphapapa
Copy link
Contributor Author

@Thiel Where did you get the pentadactyl.xpi file you're trying to install? You need one that was built since the Sep 23 commit that bumped the max version to 49. That's unrelated to extension signing.

@Thiel
Copy link

Thiel commented Oct 1, 2016

I see, thank you for the info, and sorry for it being un-related to the issue.

@mklishevych
Copy link

mklishevych commented Oct 10, 2016

@Thiel, are you sure about location/names of these files? When I create them, I get the following error message:

Configuration error.
Failed to read the configuration file. Please contact your system administrator.

UPD Looks like I was able to fix it (manually typed above code in the specified files), so now firefox starts, but it doesn't fix the problem, I still cannot activate pentadactyl because of the missing verification. I have firefox 49.0.1. Which version do you guys have?

UPD2 Argh, I've reinstalled the pentadactyl and now it works. God bless you, guys!

@nimarb
Copy link

nimarb commented Oct 14, 2016

@mklishevych , is that all you did do get it working again? It did not work for me.
I also get the same error message:

Configuration Error
Failed to read the configuration file. Please contact your system administrator.

I am running FF 49.0.1 x64 on Windows 7 x64

Which system/version of Firefox are you using or is it reasonable to expect there to be differences between the x86 and x64 versions?
Thanks!

@alphapapa
Copy link
Contributor Author

@likyng What paths did you place the files at? Did you try 1) remove Pentadactyl if it's already installed, 2) quit Firefox, 3) add the files mentioned here, 4) start Firefox, 5) install Pentadactyl?

is it reasonable to expect there to be differences between the x86 and x64 versions?

That shouldn't make any difference.

@nimarb
Copy link

nimarb commented Oct 14, 2016

@alphapapa

  1. I placed the files in C:\Program Files\Mozilla Firefox and C:\Program Files\Mozilla Firefox\defaults\pref.
    2)It was a fresh installation of Firefox (only addon which was installed before trying this method was uBlock origin)

and after trying this method the mentioned error popped up upon launching FF and thus I am not able to start it at all (even without any addons installed). When I remove the file in \defaults\pref I can start Firefox again but obviously can only install signed extensions.

@alphapapa
Copy link
Contributor Author

@likyng I see that those are the paths described in the article I linked, however I wonder if those are actually the correct paths. You might google around and see if there is another directory they should go in, maybe something in an AppData directory, something like that. I'm not sure, because I don't use Windows much; sorry I can't be of more help. Please let us know if you find out so we can add the solution here (and/or on the wiki page).

@Thiel
Copy link

Thiel commented Oct 14, 2016

In my case I've only tested in MacOS, and since the exact path wasn't specified in the article. I think I've tried to follow the relative path but didn't work, so I've brute-forced until getting something that worked ^^. And posted the result here.

@maturanomx
Copy link

maturanomx commented Oct 15, 2016

screen shot 2016-10-14 at 7 24 23 pm

$ cat /Applications/Firefox.app/Contents/Resources/defaults/pref/config-prefs.js
pref("general.config.obscure_value", 0);
pref("general.config.filename", "config.js");

$ cat /Applications/Firefox.app/Contents/Resources/config.js
try {
    Components.utils.import("resource://gre/modules/addons/XPIProvider.jsm", {})
        .eval("SIGNED_TYPES.clear()")
}
catch(ex) {}

Also I tried with config.js on /Applications/Firefox.app/ and the same result. I can't see what I'm doing wrong 😕

Mac OSX El Capitan (10.11.6)
Firefox 49.0.1

@cprn
Copy link

cprn commented Oct 23, 2016

Try adding empty lines before and after the pasted content in both files. Make sure you don't have any additional spaces, new line characters, etc., and that you have a comment in the first line of both files. It's needed.

On my new Manjaro installation it was pasting some weird white chars and simply removing them helped with the Failed to read configuration issue.

Still, I can see the changes creating these files made in about:config but can't install unverified add-ons.

Doesn't work with Firefox 49.0.1 and 49.0.2 on Manjaro i3 16.08.

@alphapapa
Copy link
Contributor Author

alphapapa commented Oct 23, 2016

@cprn Sorry to hear it doesn't work for you. I wonder if there's something different about the way Ubuntu has the Firefox build configured. If you happen to have the time and inclination, it would be very interesting if you could test Ubuntu in a VM or something and see if this works there. Maybe we could figure out how to adjust the build to make it work on other systems.

@mklishevych Could you tell us what system you're running on, what version and build of the Firefox package you have installed, etc? Since it's working for you, I'd like to compare your system with the ones it isn't working on.

@Thiel Just to clarify, you did get it working on OS X using the paths you mentioned earlier?

@cprn
Copy link

cprn commented Oct 26, 2016

@alphapapa Ignore it.

tl;dr: In order to check older version I downgraded to 49.0.1 (the only other one available in Arch repositories without reaching to ALA) and repeated every step. At that point it still didn't work for me so I posted my comment... After upgrading back to 49.0.2, however, Firefox correctly run about:newaddon?id= and so on, installing all unsigned plugins one by one. Unless someone else reports similar issue I'll let myself think it's solved.

@alphapapa
Copy link
Contributor Author

@cprn Great, glad to hear it works now!

@Thiel
Copy link

Thiel commented Oct 26, 2016

@cprn thanks for the update ^^.

@alphapapa Sorry I completely missed your previous message. And I just noticed that I made a terrible mistake by writing "pref.js" instead of "config.js" in the first part (sorry guys).

Here is a copy past of what solved my issue:

$ cat /Applications/Firefox.app/Contents/Resources/defaults/pref/test.js
pref("general.config.obscure_value", 0);
pref("general.config.filename", "config.js");
$ cat /Applications/Firefox.app/Contents/Resources/config.js
//
try {
Components.utils.import("resource://gre/modules/addons/XPIProvider.jsm", {})
.eval("SIGNED_TYPES.clear()");
}
catch(ex) {}

@maturano configuration looks correct. So I have no idea it's failing.

@haidahaha
Copy link

@Thiel 's method works for me. Don't forget the // before try in config.js

@alphapapa
Copy link
Contributor Author

@haidahaha You mean that without a // on a line by itself before the try, it doesn't work? And are you also on OS X?

@haidahaha
Copy link

haidahaha commented Oct 28, 2016

@alphapapa yes exactly. I'm on OS X 10.11.3. WIthout a // I got the configuration error like @maturano above

@alphapapa
Copy link
Contributor Author

@haidahaha Thanks, that's very good info. I'll add it to the wiki page.

@Thiel
Copy link

Thiel commented Oct 31, 2016

Thanks @haidahaha for figuring that out ^^.

Out of curiosity, does anyone know the reason behind // ?

@nimarb
Copy link

nimarb commented Nov 2, 2016

@alphapapa the config file from @Thiel (incl. the comment) also works on my windows 7 machine! Thanks a lot!!!!!

@insidewhy
Copy link

You can also use the "unbranded" binaries built here: https://archive.mozilla.org/pub/firefox/tinderbox-builds/mozilla-release-linux64-add-on-devel/

On archlinux it's in the AUR.

@cprn
Copy link

cprn commented Nov 23, 2016

// is just a comment... It doesn't mean anything but it's needed in the first line for Firefox to parse the file correctly. If it isn't in the first line, it's also possible you've copy&pasted some unprintable character that bugs the interpreter and commenting it solves the issue. Deleting white space will solve it in that case.

@alphapapa
Copy link
Contributor Author

@ohjames Yeah, here's hoping other Linux distros will also provide builds like that.

@cprn Thanks for pointing that out. That would explain why some people don't have that problem.

@hari-rangarajan
Copy link

I got it installed on FF 51 with the techniques noted above and bypassing the max version. The plugin does not seem to load; a stack trace shows up:

1487094198770 addons.xpi WARN Error loading bootstrap.js for

[email protected]: TypeError: can't convert undefined to object (resource://gre/modules/addons/XPIProvider.jsm -> jar:file:///home/hari/.mozilla/firefox/5sumaxhy.default/extensions/[email protected]!/bootstrap.js:20:1) JS Stack trace: @resource://gre/modules/addons/XPIProvider.jsm -> jar:file:///home/hari/.mozilla/firefox/5sumaxhy.default/extensions/[email protected]:20:1 < @XPIProvider.jsm:4796:1 < [email protected]:4796:7 < [email protected]:4875:9 < [email protected]:2868:13 < [email protected]:235:12 < [email protected]:788:5 < [email protected]:972:9 < [email protected]:3016:5 < [email protected]:71:9
undefined: bootstrap: startup startup
1487094198772 addons.xpi WARN Exception running bootstrap method startup on [email protected]: ReferenceError: can't access lexical declaration `initialized' before initialization (resource://gre/modules/addons/XPIProvider.jsm -> jar:file:///home/hari/.mozilla/firefox/5sumaxhy.default/extensions/[email protected]!/bootstrap.js:361:9) JS Stack trace: startup@resource://gre/modules/addons/XPIProvider.jsm -> jar:file:///home/hari/.mozilla/firefox/5sumaxhy.default/extensions/[email protected]:361:9 < [email protected]:4944:9 < [email protected]:2868:13 < [email protected]:235:12 < [email protected]:788:5 < [email protected]:972:9 < [email protected]:3016:5 < [email protected]:71:9

@alphapapa
Copy link
Contributor Author

@hari-rangarajan That would be a different problem that should be discussed in a separate issue. This is only for discussing how to work around XPI signing.

@uBlock-magic
Copy link

uBlock-magic commented May 30, 2017

Any Idea how to install addons with label Compatible with Firefox 57+?
For example:

  • ColorZilla
  • Disconnect
  • Evernote Web Clipper
  • Tab Auto Refresh

@alphapapa
Copy link
Contributor Author

@uBlock-magic This is only for discussing how to work around XPI signing for Pentadactyl, not a general extension support forum.

@ghost
Copy link

ghost commented Oct 26, 2017

Any Idea how to install addons with label Compatible with Firefox 57+?
For example:

ColorZilla
Disconnect
Evernote Web Clipper
Tab Auto Refresh

Script die in Firefox 51+, install no problem 👍

@CoolCmd
Copy link

CoolCmd commented Nov 21, 2017

@cprn

// is just a comment... if you need it in order for this workaround to work, it means you've copy&pasted some unprintable character that bugs the interpreter and commenting it solves the issue. Deleting white space will solve it as well.

No. Comment is needed because Firefox ignores the first line of this file. See MDN.

@cprn
Copy link

cprn commented Nov 21, 2017

@CoolCmd Thanks, you're right.
@alphapapa Can you update the first post so it would include comments in first line of both config.js and config-prefs.js?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests