How do you retrieve the extension ID from the xpi file? (It is needed f.ex. for global extension installation)
In previous versions, you could get it from the install.rdf
, which no longer exists in WebExtensions. http://www.di-mgt.com.au/how-mozilla-signs-addons.html describes that it is contained in the META-INF/mozilla.rsa
file.
In python, there is the pyasn1 library. I could not get it to work on the first attempt:
from pyasn1.codec.der import decoder
f = open('/path/to/addon-dir/META-INF/mozilla.rsa')
decoder.decode(f)
gave
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/lib/python2.7/dist-packages/pyasn1/codec/ber/decoder.py", line 623, in __call__
raise error.PyAsn1Error('Bad octet stream type')
pyasn1.error.PyAsn1Error: Bad octet stream type
This hack worked:
It relies on
asn1parse
, and{
belongs to the idAnything more elegant is appreciated.
The
decode
method want a buffer (string), not a file object. Use:Worked for me.
Edit:
The
pyasn1_modules
package includes classes that represent some common PKCS structs. You can start with something like this:This produces output similar to
openssl asn1parse -inform DER -in mozilla.rsa
(I myself preferpyasn1
's indentation overopenssl
's "d=depth".)If you want to further parse it using
pyasn1
you can try something like:The major problem is here is that I'm doing something kind awful to get the string in the marked line, but except for this I don't think you can get much better.
If you find out how to get the string properly please share.