Skip to content

Instantly share code, notes, and snippets.

@bodja
Created July 9, 2015 12:12
Show Gist options
  • Save bodja/dbce4bfab870b542415e to your computer and use it in GitHub Desktop.
Save bodja/dbce4bfab870b542415e to your computer and use it in GitHub Desktop.
derkey = Popen(['openssl', 'rsa', '-pubout', '-outform', 'DER', '-inform',
'PEM', '-in', path_to_pem_key], stdout=PIPE).stdout.read()
signature = Popen(['openssl', 'sha1', '-sha1', '-sign', path_to_pem_key,
zip_file.filename], stdout=PIPE).stdout.read()
with open('extension.crx', 'w') as crx:
crx.writelines(['Cr24',
struct.pack("<I", 2), # crx version
struct.pack("<I", len(derkey)),
struct.pack("<I", len(signature)),
derkey,
signature,
open(zip_file.filename, 'r').read()])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment