forked from Sienci-Labs/gsender
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathWindowsSigner.js
31 lines (24 loc) · 864 Bytes
/
WindowsSigner.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
const { execSync } = require('child_process');
/**
* Custom signing utility
* Required environment variables:
* KEYPAIR_ALIAS - KSP keypair from Digicert
* @param config
* @returns {Promise<void>}
*/
// eslint-disable-next-line require-await
exports.default = async (config) => {
const keypairAlias = 'key_612024263';
const path = config.path ? String(config.path) : '';
if (process.platform !== 'win32' || !keypairAlias || !path) {
throw new Error('Either win32, no keypair or path not found');
}
const output = execSync(
`smctl sign --keypair-alias=${keypairAlias} --certificate="C:/Certs/sienci.p12" --input="${path}" --verbose`,
)
.toString()
.trim();
if (!output.includes('Done Adding Additional Store')) {
throw new Error(`Failed to sign executable: ${output}`);
}
};