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

afterSign hook is triggered before code signing happens #3504

Closed
davej opened this issue Nov 27, 2018 · 3 comments
Closed

afterSign hook is triggered before code signing happens #3504

davej opened this issue Nov 27, 2018 · 3 comments

Comments

@davej
Copy link
Contributor

davej commented Nov 27, 2018

  • Version: 20.37.0
  • Target: Mac

Config option looks like:

afterSign() {
  console.log("after sign handler called");
}

Console output looks like this.

after sign handler called
  • signing         file=/{snipped}/dist/mac/TestApp.app identityName=Developer ID Application: Dave Jeffery (SN1PP3D) identityHash=446B886736EC179EF88B902E0515A166202A5FFF provisioningProfile=none
@davej davej changed the title afterSign is triggered before code signing happens afterSign hook is triggered before code signing happens Nov 27, 2018
@Kilian
Copy link
Contributor

Kilian commented May 21, 2019

Still the case in 20.41.0

@Kilian
Copy link
Contributor

Kilian commented May 21, 2019

It's probably because the call here:

await this.signApp(packContext, isAsar)

links to a function that resolves immediately:

protected signApp(packContext: AfterPackContext, isAsar: boolean): Promise<any> {
return Promise.resolve()
}

whereas the signing function for mac seems to be called just 'sign', and not 'signApp':

private async sign(appPath: string, outDir: string | null, masOptions: MasConfiguration | null): Promise<void> {

What happens is that in the following code, it checks for non-MAS, or target of more than one. If you're building just a DMG, then MAS will be false but it will also be creating a ZIP, setting the target count to two.

if (!hasMas || targets.length > 1) {
const appPath = prepackaged == null ? path.join(this.computeAppOutDir(outDir, arch), `${this.appInfo.productFilename}.app`) : prepackaged
nonMasPromise = (prepackaged ? Promise.resolve() : this.doPack(outDir, path.dirname(appPath), this.platform.nodeName as ElectronPlatformName, arch, this.platformSpecificBuildOptions, targets))
.then(() => this.sign(appPath, null, null))
.then(() => this.packageInDistributableFormat(appPath, Arch.x64, targets, taskManager))
}

In this function, the entire doPack function is called first (that function includes the afterSign call and the await this.signApp that immediately resolves) and only after that function is resolved, calls the local sign function.

It seems to me the macPackager file needs to be updated: the sign function needs to be renamed to signApp so it's correctly called in the doPack function, and .then(() => this.sign(appPath, null, null)) on line 89 should be removed.

edit: no, macPackager needs a signApp call just like winPackager has (and the then() should be removed, if signing already happens in the doPack step)

@Kilian
Copy link
Contributor

Kilian commented May 25, 2019

This ticket can be closed, now that #3912 is merged 🎉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants