Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Migrate to Logitech code signing infrastructure #5312

Merged
merged 8 commits into from
Feb 20, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 20 additions & 3 deletions electron-builder/afterPack.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
const cp = require('child_process');
const fs = require('fs');
const path = require('path');
const os = require('os');

function signAndCheck(identity, filePath) {
console.log(`Signing: ${filePath}`);
Expand Down Expand Up @@ -50,9 +51,7 @@
}
}

exports.default = async function(context) {
if (process.platform !== 'darwin') return;

function afterPackMac() {
console.log('Updating dependency paths');
cp.execSync(
`install_name_tool -change ./node_modules/node-libuiohook/libuiohook.1.dylib @executable_path/../Resources/app.asar.unpacked/node_modules/node-libuiohook/libuiohook.1.dylib \"${context.appOutDir}/${context.packager.appInfo.productName}.app/Contents/Resources/app.asar.unpacked/node_modules/node-libuiohook/node_libuiohook.node\"`,
Expand All @@ -72,4 +71,22 @@
context.packager.config.mac.identity,
`${context.appOutDir}/${context.packager.appInfo.productName}.app/Contents/Resources/app.asar.unpacked`,
);
}

function afterPackWin() {
if (process.env.SLOBS_NO_SIGN) return;

// Ensure an empty signing manifest file
const signingPath = path.join(os.tmpdir(), 'sldesktopsigning');
fs.writeFileSync(signingPath, '', { flag: 'w' });
}

exports.default = async function(context) {
if (process.platform === 'darwin') {
afterPackMac();
}

if (process.platform === 'win32') {
afterPackWin();
}
};
28 changes: 27 additions & 1 deletion electron-builder/notarize.js → electron-builder/afterSign.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
const { notarize } = require('@electron/notarize');
const fs = require('fs');
const cp = require('child_process');
const path = require('path');
const os = require('os');

exports.default = async function notarizing(context) {
async function notarizeMac() {
if (process.env.SLOBS_NO_NOTARIZE) return;
if (process.platform !== 'darwin') return;

Expand All @@ -25,4 +28,27 @@ exports.default = async function notarizing(context) {
});

console.log('Notarization finished.');
}

async function afterPackWin() {
if (process.env.SLOBS_NO_SIGN) return;

const signingPath = path.join(os.tmpdir(), 'sldesktopsigning');

if (fs.existsSync(signingPath)) {
cp.execSync(`logisign client --client logitech-cpg-sign-client --app streamlabs --filelist ${signingPath}`, { stdio: 'inherit' });
fs.unlinkSync(signingPath);
} else {
throw new Error('EXPECTED TO SIGN BINARIES BUT SIGNING MANIFEST IS MISSING');
}
}

exports.default = async function afterSign(context) {
if (process.platform === 'darwin') {
await notarizeMac();
}

if (process.platform === 'win32') {
await afterPackWin();
}
};
23 changes: 14 additions & 9 deletions electron-builder/base.config.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
const signtool = require('signtool');
const fs = require('fs');
const path = require('path');
const os = require('os');
const cp = require('child_process');

const base = {
appId: 'com.streamlabs.slobs',
Expand Down Expand Up @@ -41,6 +45,7 @@
rfc3161TimeStampServer: 'http://timestamp.digicert.com',
timeStampServer: 'http://timestamp.digicert.com',
signDlls: true,
signingHashAlgorithms: ['sha256'],
async sign(config) {
if (process.env.SLOBS_NO_SIGN) return;

Expand All @@ -52,14 +57,14 @@
}

console.log(`Signing ${config.hash} ${config.path}`);
await signtool.sign(config.path, {
subject: 'Streamlabs (General Workings, Inc.)',
rfcTimestamp: 'http://timestamp.digicert.com',
algorithm: config.hash,
append: config.isNest,
description: config.name,
url: config.site,
});

const signingPath = path.join(os.tmpdir(), 'sldesktopsigning');

if (fs.existsSync(signingPath)) {
fs.appendFileSync(signingPath, `${config.path}\n`);
} else {
cp.execSync(`logisign client --client logitech-cpg-sign-client --app streamlabs --files "${config.path}"`, { stdio: 'inherit' });
}
},
},
mac: {
Expand Down Expand Up @@ -117,7 +122,7 @@
},
beforePack: './electron-builder/beforePack.js',
afterPack: './electron-builder/afterPack.js',
afterSign: './electron-builder/notarize.js',
afterSign: './electron-builder/afterSign.js',
};

module.exports = base;
Loading