def gen_xpi_update_rdf(self, out): xpi_data = StringIO() self.gen_xpi(xpi_data) update_hash = hashlib.sha1(xpi_data.getvalue()).hexdigest() properties = {} properties.update(self.get_xpi_manifest()) properties.update({'update_hash': update_hash}) updates = os.path.join(os.path.dirname(__file__), 'xpi_updates') normalized = str(Template(open(os.path.join(updates, 'update_normalized.rdf')).read()).render(Context(properties))) openssl_signer = subprocess.Popen(['openssl', 'dgst', '-sha512', '-hex', '-sign', getattr(self, 'pem_path', None)], stdin=subprocess.PIPE, stdout=subprocess.PIPE) sig = openssl_signer.communicate(normalized)[0].strip() RSA = ASN1Algorithm() RSA.setComponentByName('oid', (1, 2, 840, 113549, 1, 1, 13)) asn1sig = ASN1Signature() asn1sig.setComponentByName('alg', RSA) asn1sig.setComponentByName('seq', "'%s'H" % sig) rdf_signature = base64.b64encode(encoder.encode(asn1sig)) properties.update({'rdf_signature': rdf_signature}) out.write(str(Template(open(os.path.join(updates, 'update.rdf')).read()).render(Context(properties))))
def gen_xpi_update_rdf(self, out): xpi_data = StringIO() self.gen_xpi(xpi_data) update_hash = hashlib.sha1(xpi_data.getvalue()).hexdigest() properties = {} properties.update(self.get_xpi_manifest()) properties.update({'update_hash': update_hash}) updates = os.path.join(os.path.dirname(__file__), 'xpi_updates') normalized = str( Template( open(os.path.join(updates, 'update_normalized.rdf')).read()).render( Context(properties))) openssl_signer = subprocess.Popen([ 'openssl', 'dgst', '-sha512', '-hex', '-sign', getattr(self, 'pem_path', None) ], stdin=subprocess.PIPE, stdout=subprocess.PIPE) sig = openssl_signer.communicate(normalized)[0].strip() RSA = ASN1Algorithm() RSA.setComponentByName('oid', (1, 2, 840, 113549, 1, 1, 13)) asn1sig = ASN1Signature() asn1sig.setComponentByName('alg', RSA) asn1sig.setComponentByName('seq', "'%s'H" % sig) rdf_signature = base64.b64encode(encoder.encode(asn1sig)) properties.update({'rdf_signature': rdf_signature}) out.write( str( Template(open(os.path.join(updates, 'update.rdf')).read()).render( Context(properties))))