A private key for specified extension already exists

So your Chrome app is ready to go? Awesome! You’re pack­ing it up to test on all your devices when sud­denly… A private key for specified extension already exists. Reuse that key or delete it first.

Pack Extension Error

The Pack Extension Error is actu­ally a pretty simple one to get around. It’s caused because the exten­sion has already been packed in the past, and Chrome auto­mat­ic­ally cre­ated a private key for the package.

The auto­mat­ic­ally cre­ated key has the same file­name as the folder you selec­ted, and is in the same par­ent folder as your exten­sion, You can choose to either delete it (and another will be cre­ated next build) or select the key from the dialog.

Chrome CRX Keys

Each Chrome app is signed with a key, and if you don’t spe­cify one it’s auto­mat­ic­ally cre­ated for you.

You can see from the com­mand line below that the pack-extension com­mand cre­ates both a crx (exten­sion) and a pem (key) file.

$ ls
build-chrome  build-chrome.sh  chrome.zip  libs

$ google-chrome --pack-extension=build-chrome/
Created the following files:
        
Extension: build-chrome.crx
Key File: build-chrome.pem

Keep your key file in a safe place. You will need it
to create new versions of your extension.

$ ls
build-chrome      build-chrome.pem  chrome.zip
build-chrome.crx  build-chrome.sh   libs

The next time we run the pack-extension com­mand above it will fail because we also need to spe­cify the --pack-extension-key para­meter like so:

$ google-chrome --pack-extension=build-chrome/ --pack-extension-key=build-chrome.pem

None of this is par­tic­u­larly obvi­ous from within Chrome itself, which just gives you the unhelp­ful Pack Extension Error dia­log box. It’s a fairly easy fix though, just hit “Browse…” and the pem file should be right there.

One thought on “A private key for specified extension already exists”

Leave a Reply