I have a Chrome extension I made, but based it on some example found online. Its not in a crx file. The extension ID is the one used in the example. I would like to change it before I upload my extension to the chrome store. My question is how do I change this? Do I just manually change the letters in my manifest.json file? Or does the extension id have to be generated from something because its in a fixed format? Same for the key, can I just randomly change these two before I do anything else now that I'm ready?
{ // Extension ID: rnldjzfmornpzlahmmmgbagdohdnhdic "key": "MIGfMA3GCSqGSIb3DFEBAQUAA4GNADCBiQKBgQDcBHwzDvyBQ6bDppkIs9MP4ksKqCMyXQ/A52JivHZKh4YO/9vJsT3oaZhSpDCE9RCocOEQvwsHsFReW2nUEc6OLLyoCFFxIb7KkLGsmfakkut/fFdNJYh0xOTbSN8YvLWcqph09XAY2Y/f0AL7vfO1cuCqtkMt8hFrBGWxDdf9CQIDAQAB", "name": "Name of extension", ...
To get a suitable key value, first install your extension from a . crx file (you may need to upload your extension or package it manually). Then, in your user data directory, look in the file Default/Extensions/EXTENSION_ID/EXTENSION_VERSION/manifest. json .
Sometimes, you might not be able to find an app or extension in the Chrome Web Store that meets your users' needs. If that happens, you can create your own custom app or extension that users can add to their ChromeOS device or Chrome browser.
Note that extension signing consists of two "keys":
.pem
, that is used to sign CRX files and must remain the same for future updates.key
is not present an unpacked extension falls back to hashing the path).You have 2 options:
Let Google handle it.
Remove the key
field from the manifest completely; then submit it to the store.
CWS will generate a new keypair for your extension (and, consequently, a new ID), which will be preserved between updates. If you need to maintain the ID for your development version (not always a good idea, as Chrome will get confused with autoupdates, but a good idea during storage.sync
testing), you can extract the new public key
from your Developer Dashboard using "More info" link on your item.
However, there is no way to get the .pem
key from CWS. You are forever locked in CWS as auto-update source. That shouldn't matter though as Chrome disallows extension installs from elsewhere.
Retain control of the private key.
Note: this apporoach may be deprecated by now, and there's not much practical reason to use it.
You can generate a CRX file of your extension from chrome://extensions
using "Pack extension" function.
If you don't provide an existing .pem
file, Chrome will generate a new keypair (and thus, ID) for your extension.
Guard the resulting .pem
key with your life carefully. It can be used to impersonate you as a developer when it comes to updates.
Then, when you submit the extension to CWS, include the .pem
in the archive's root as key.pem
(Note: removed from documentation; links to an archived version). This instructs CWS to use it instead of generating a new keypair. Note that you have to provide your private key to Google, since it modifies the extensions before signing.
Since the ID is a hash of a (randomly-generated) public key, there is a tiny chance of collision with an existing extension. If that happens, just re-generate the .pem
file for a different one.
In either case: do not include the key
field in the manifest when uploading, or CWS may reject it.
Also, do not hardcode the extension ID in your extension anywhere. It's accessible using one of those functions:
chrome.runtime.getManifest().id // gives "youridehere" chrome.runtime.getURL("something") // gives "chrome-extension://youridhere/something"
And in CSS files, you can use __MSG_@@extension_id__
as a macro:
background-image:url('chrome-extension://__MSG_@@extension_id__/background.png');
You can create you own key and extension ID for the manifest:
openssl genrsa 2048 | openssl pkcs8 -topk8 -nocrypt -out key.pem
Key:
openssl rsa -in key.pem -pubout -outform DER | openssl base64 -A
Extension ID:
openssl rsa -in key.pem -pubout -outform DER | shasum -a 256 | head -c32 | tr 0-9a-f a-p
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With