Skip to content

Commit dcf9b1e

Browse files
committed
log checksums before and after signing
1 parent 3dd51f0 commit dcf9b1e

File tree

1 file changed

+19
-1
lines changed

1 file changed

+19
-1
lines changed

packages/hadron-build/lib/signtool.js

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
'use strict';
2+
const fs = require('fs');
3+
const crypto = require('crypto');
24
const path = require('path');
35
const debug = require('debug')('hadron-build:target');
46
const { sign: _garasign } = require('@mongodb-js/signing-utils');
@@ -51,6 +53,20 @@ function getSigningMethod(src) {
5153
}
5254
}
5355

56+
function hashFile(filename) {
57+
return new Promise((resolve, reject) => {
58+
const hash = crypto.createHash('sha256');
59+
const fh = fs.createReadStream(filename);
60+
61+
fh.on('data', d => hash.update(d));
62+
fh.on('end', () => {
63+
const digest = hash.digest('hex');
64+
resolve(digest);
65+
});
66+
fh.on('error', reject);
67+
});
68+
}
69+
5470
/**
5571
* We are signing the file using `gpg` or `jsign` depending on the
5672
* file extension. If the extension is `.exe` or `.msi`, we use `jsign`
@@ -76,7 +92,9 @@ async function sign(src, garasign = _garasign) {
7692
signingMethod: getSigningMethod(src),
7793
};
7894

79-
return await garasign(src, clientOptions);
95+
debug(`checksum of ${src} before signing: ${await hashFile(src)}`);
96+
await garasign(src, clientOptions);
97+
debug(`checksum of ${src} after signing: ${await hashFile(src)}`);
8098
}
8199

82100
module.exports = { sign, signArchive, getSignedFilename };

0 commit comments

Comments
 (0)