Javascript 尝试在 Firefox 中安装我的加载项的 .xpi 文件时加载项“似乎已损坏”

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/39854127/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-23 22:58:37  来源:igfitidea点击:

Add-on "appears to be corrupt" when trying to install my add-on's .xpi file in Firefox

javascriptfirefoxfirefox-addonxpi

提问by ndarriulat

I am trying to install an extension in Firefox 45 (same happens with Firefox 49), but Firefox does not allow me to do that, indicating that

我正在尝试在 Firefox 45 中安装扩展(Firefox 49 也是如此),但 Firefox 不允许我这样做,表明

This add-on could not be installed because it appears to be corrupt. 

The way I am trying to install it is simply by dragging the .xpi fileour team developed, into the Firefox window. This extension is based on MozRepl, but with some improvements.

我尝试安装它的方法只是我们团队开发的 .xpi 文件拖到Firefox 窗口中。此扩展基于MozRepl,但有一些改进。

Previously, I tried to install it but I couldn't as it was not signed (extensions in Firefox versions from 43 onwards require signing). I followed every step in order to sign it, according to this post: Signing a XPI. I am almost certain I could sign it correctly, but now the error Firefox displays is different: "This add-on could not be installed because it appears to be corrupt."

以前,我尝试安装它但我无法安装,因为它没有签名(Firefox 43 及以后版本中的扩展需要签名)。根据这篇文章,我按照每个步骤进行签名:签署 XPI。我几乎可以肯定我可以正确签名,但现在 Firefox 显示的错误有所不同:“无法安装此附加组件,因为它似乎已损坏。”

enter image description here

在此处输入图片说明

It seems that I am not creating the .xpi file correctly, but I am not sure which is the correct structure it should have. I tried different folder structures, but with no success.

似乎我没有正确创建 .xpi 文件,但我不确定它应该具有哪个正确的结构。我尝试了不同的文件夹结构,但没有成功。

Also, I checked the Browser Console to see what error is logged in, but I didn't found it really helpful. Here it is:

此外,我检查了浏览器控制台以查看登录的错误,但我没有发现它真的很有帮助。这里是:

enter image description here

在此处输入图片说明

Hereis a link to the .xpi file in case you want to check its content. Note that I tried moving the files manifest.mf, zigbert.rsa and zigbert.sf outside the META-INF folder, but it didn't work either.

是 .xpi 文件的链接,以防您想检查其内容。请注意,我尝试将文件 manifest.mf、zigbert.rsa 和 zigbert.sf 移到 META-INF 文件夹之外,但它也不起作用。

Has anyone stumbled across an error like this when trying to install an add-on? Any ideas of what maybe happening?

有没有人在尝试安装附加组件时遇到过这样的错误?关于可能发生什么的任何想法?

采纳答案by Makyen

The .xpifile must use only"deflate" compression or uncompressed

的.xpi文件必须使用唯一的“deflate”压缩或解压缩

The zip implementation within Firefox only supports uncompressed files or files compressed with the "Deflate" algorithm. You will need to create the .ziparchive using the compression method "Deflate" instead of the "LZMA" which you are currently using. How to do so will depend on the tools you use to create your archive.

Firefox 中的 zip 实现仅支持未压缩文件或使用“Deflate”算法压缩的文件。您将需要使用压缩方法“Deflate”而不是您当前使用的“LZMA”来创建.zip存档。如何做到这一点取决于您用来创建档案的工具。

Personally, I use a batch file/shell script to create the .xpifile as I describe in detail in my answer to "Firefox extension .xpi file structure: description, contents, creation, and installation". The basics are that I use the zipcommand line tool which defaults to "deflate" or uncompressed. I use the -1option to provide the fastest compression. Firefox/Mozilla use .xpifiles both to package the files, but to also increase file access speed. The important quality is not a high compression ratio, but that the files can be accessed quickly. Unless Firefox is not an WebExtension and explicitly told to unpack the add-on by the install.rdfoption <em:unpack>true</em:unpack>(WebExtensions don't have install.rdffiles), the add-on will be installed as the .xpifile and all access to the add-on will be as the .xpifile.

就我个人而言,我使用批处理文件/shell 脚本来创建.xpi文件,正如我在“ Firefox 扩展 .xpi 文件结构:描述、内容、创建和安装”的回答中详细描述的那样。基础是我使用zip默认为“放气”或未压缩的命令行工具。我使用该-1选项来提供最快的压缩。Firefox/Mozilla 使用.xpi文件来打包文件,同时也提高文件访问速度。重要的质量不是高压缩率,而是可以快速访问文件。除非 Firefox 不是 WebExtension 并且通过install.rdf选项明确告知要解压附加组件<em:unpack>true</em:unpack>(WebExtensions 没有install.rdf文件),附加组件将作为.xpi文件安装,并且对附加组件的所有访问都将作为.xpi文件。

Note: Given that your extension contains .dllfiles, you may need to have your add-on installed unpacked by using <em:unpack>true</em:unpack>.

注意:鉴于您的扩展程序包含.dll文件,您可能需要使用.dll文件解压安装的附加组件<em:unpack>true</em:unpack>

Wrong signing method used. It must be signed by Mozilla, not yourself.

使用了错误的签名方法。它必须由 Mozilla 签名,而不是您自己。

While it is not the error you are currently seeing, as soon as you fix the problem with your .xpiformat, you will encounter an issue with your extension being signed by the wrong signature. You signed your extension with your own signature. It was not signed by Mozilla. This will not work. It must be signed by Mozilla, not yourself.You mentioned that you followed the directions in the MDN page Signing an XPI. However, as is clearly stated at the top of that page, the directions on that page are outdated and no longer work. You should have followed the link in the note to the page Signing and distributing your add-on. The note at the top of the page states:

虽然这不是您当前看到的错误,但是一旦您解决了.xpi格式的问题,您就会遇到扩展程序被错误签名签名的问题。您使用自己的签名签署了扩展程序。它没有由 Mozilla 签署。这是行不通的。它必须由 Mozilla 签名,而不是您自己。您提到您遵循了 MDN 页面Signing an XPI 中的指示。但是,正如该页面顶部明确指出的那样,该页面上的说明已过时且不再有效。您应该按照注释中的链接转到Signing and distributing your add-on 页面。页面顶部的注释指出:

Note: These instructions are outdated. For an extension to work in Firefox it must be signed by Mozilla, not by yourself. See Signing and distributing your add-on. [Emphasis added]

注意:这些说明已过时。要在 Firefox 中使用扩展,它必须由 Mozilla 签名,而不是由您自己签名。请参阅签署和分发您的附加组件。[强调]

There are also a variety of questions here on Stack Overflow which address the signing issue.

Stack Overflow 上还有很多问题可以解决签名问题。

回答by Rohit

Like stated in other answer it happens for unverified/unsigned extension.

就像其他答案中所述,它发生在未经验证/未签名的扩展中。

But sometimes for testing you might want to use unverified/unsigned extension. As a hack/workaround to install unverified/unsigned extensions following worked for me on Firefox version 45:

但有时为了测试,您可能想要使用未经验证/未签名的扩展名。作为安装未经验证/未签名的扩展的黑客/解决方法,以下在 Firefox 版本 45 上对我有用:

  1. Launch Firefox and hit - about:config
  2. Search for 'xpinstall.signatures.required'
  3. Either double click on the row OR set the value to false and close
  1. 启动 Firefox 并点击 - about:config
  2. 搜索“xpinstall.signatures.required”
  3. 双击该行或将值设置为 false 并关闭

Now retry installing the extension and it should work.

现在重试安装扩展,它应该可以工作。

回答by Andrew

I had this issue when I compressed the folder containing my addon rather then just the files within.

当我压缩包含我的插件的文件夹而不是其中的文件时,我遇到了这个问题。

Don't Compress the Parent Folder of your Manifest

不要压缩清单的父文件夹

Screenshot

截屏

For example, on Windows CTRL+Click on your manifest and any other files or subfolders;right click and select Send to > Compressed Folderand you should be good to go.

例如,在 Windows 上 CTRL+单击您的清单和任何其他文件或子文件夹;右键单击并选择Send to > Compressed Folder,您应该很高兴。

Note: from the browser console screenshot we can tell this isn't the issue in this case, but even so this is a common problem to the This add-on could not be installed because it appears to be corrupterror.

注意:从浏览器控制台屏幕截图我们可以看出这不是这种情况下的问题,但即便如此,这也是This add-on could not be installed because it appears to be corrupt错误的常见问题。

回答by Mert Buran

I think there is something not clearly documented, I'd like to share my experience.

我认为有些事情没有明确记录,我想分享我的经验。

  1. Developed my extension and zipped all the files
  2. Selected On your ownfor How to Distribute this Versionstep and uploaded .zipto AMO
  3. Then, on the next page, I see a signed .xpifile available for download. I downloaded it and tried to install via "about:addons -> Install Add-on from file"
    1. I get corrupt add-onerror in this case
  4. After receiving e-mail from [email protected], I went to my add-on's page and clicked on .xpifile link there and it worked!
  1. 开发我的扩展程序并处理zip所有文件
  2. 所选On your ownHow to Distribute this Version一步,并上传.zipAMO
  3. 然后,在下一页上,我看到一个.xpi可供下载的签名文件。我下载了它并尝试通过“about:addons -> Install Add-on from file”安装
    1. corrupt add-on在这种情况下我收到错误
  4. 收到来自 的电子邮件后[email protected],我转到我的附加组件页面并单击.xpi那里的文件链接,它起作用了!

enter image description here

在此处输入图片说明