Left: | ||
Right: |
LEFT | RIGHT |
---|---|
1 # This Source Code Form is subject to the terms of the Mozilla Public | 1 # This Source Code Form is subject to the terms of the Mozilla Public |
2 # License, v. 2.0. If a copy of the MPL was not distributed with this | 2 # License, v. 2.0. If a copy of the MPL was not distributed with this |
3 # file, You can obtain one at http://mozilla.org/MPL/2.0/. | 3 # file, You can obtain one at http://mozilla.org/MPL/2.0/. |
4 | 4 |
5 import base64 | 5 import base64 |
6 import ConfigParser | 6 import ConfigParser |
7 import json | 7 import json |
8 import os | 8 import os |
9 import re | 9 import re |
10 from urlparse import urlparse | 10 from urlparse import urlparse |
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
117 data = file.read() | 117 data = file.read() |
118 | 118 |
119 certificates = [] | 119 certificates = [] |
120 key = None | 120 key = None |
121 for match in re.finditer(r'-+BEGIN (.*?)-+(.*?)-+END \1-+', data, re.S): | 121 for match in re.finditer(r'-+BEGIN (.*?)-+(.*?)-+END \1-+', data, re.S): |
122 section = match.group(1) | 122 section = match.group(1) |
123 if section == 'CERTIFICATE': | 123 if section == 'CERTIFICATE': |
124 certificates.append(base64.b64decode(match.group(2))) | 124 certificates.append(base64.b64decode(match.group(2))) |
125 elif section == 'PRIVATE KEY': | 125 elif section == 'PRIVATE KEY': |
126 key = RSA.importKey(match.group(0)) | 126 key = RSA.importKey(match.group(0)) |
127 if key is None: | 127 if not key: |
Sebastian Noack
2016/08/17 18:34:11
Nit: Use |not x| instead |x is None| if it doesn't
Wladimir Palant
2016/08/17 19:21:12
Done.
| |
128 raise Exception('Cound not find private key in file') | 128 raise Exception('Could not find private key in file') |
Sebastian Noack
2016/08/17 18:34:11
Typo: Cound -> Couldn't
Wladimir Palant
2016/08/17 19:21:12
Done.
| |
129 | 129 |
130 return certificates, key | 130 return certificates, key |
131 | 131 |
132 | 132 |
133 def _get_sequence(data): | 133 def _get_sequence(data): |
134 from Crypto.Util import asn1 | 134 from Crypto.Util import asn1 |
135 sequence = asn1.DerSequence() | 135 sequence = asn1.DerSequence() |
136 sequence.decode(data) | 136 sequence.decode(data) |
137 return sequence | 137 return sequence |
138 | 138 |
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
288 fixAbsoluteUrls(files) | 288 fixAbsoluteUrls(files) |
289 | 289 |
290 dirname = metadata.get('general', 'basename') + '.safariextension' | 290 dirname = metadata.get('general', 'basename') + '.safariextension' |
291 for filename in files.keys(): | 291 for filename in files.keys(): |
292 files[os.path.join(dirname, filename)] = files.pop(filename) | 292 files[os.path.join(dirname, filename)] = files.pop(filename) |
293 | 293 |
294 if not devenv and keyFile: | 294 if not devenv and keyFile: |
295 createSignedXarArchive(outFile, files, certs, key) | 295 createSignedXarArchive(outFile, files, certs, key) |
296 else: | 296 else: |
297 files.zip(outFile) | 297 files.zip(outFile) |
LEFT | RIGHT |