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

fix(codeSign): signing with 'Mac Developer' failed #1103

Closed
wants to merge 1 commit into from
Closed

fix(codeSign): signing with 'Mac Developer' failed #1103

wants to merge 1 commit into from

Conversation

ericzhangjx
Copy link

Removed codes of throwing exceptions inside findIdentity(), and let the sign() in macPackager.ts itself handle the returned value of findIdentity() (which should be string|null) and then try to sign with certType==='Mac Developer' before exporting unsigned application;

Removed codes of throwing exceptions inside `findIdentity()`, and let the `sign()` in `macPackager.ts` itself handle the returned value of `findIdentity()` (which should be string|null) and then try to sign with certType==='Mac Developer' before exporting unsigned application;
Copy link
Member

@develar develar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Due to security reasons for Pull Request testing of mas/mac code signing is not possible. Only for upstream changes or locally. So, I have to run tests manually to test. Have you run yarn test locally?

@@ -10,7 +10,7 @@ import { homedir } from "os"
import { statOrNull } from "electron-builder-util/out/fs"
import isCi from "is-ci"

export const appleCertificatePrefixes = ["Developer ID Application:", "Developer ID Installer:", "3rd Party Mac Developer Application:", "3rd Party Mac Developer Installer:"]
export const appleCertificatePrefixes = ["Developer ID Application:", "Developer ID Installer:", "3rd Party Mac Developer Application:", "3rd Party Mac Developer Installer:", "Mac Developer:"]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not necessary and can lead to major issues.

throw new Error(`Identity name "${identity}" is specified, but no valid identity with this name in the keychain`)
}
return result
return await _findIdentity(certType, identity, keychain)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If check removed here, it should be added to macPackager.ts

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

macPackager.ts

    let name = await findIdentity(isMas ? "3rd Party Mac Developer Application" : "Developer ID Application", isMas ? masQualifier : this.platformSpecificBuildOptions.identity, keychainName)
    if (name == null) {
      if (!isMas) {
        name = await findIdentity("Mac Developer", this.platformSpecificBuildOptions.identity, keychainName)
        if (name != null) {
          warn("Mac Developer is used to sign app — it is only for development and testing, not for production")
        }
      }

      if (name == null) {
        const message = process.env.CSC_IDENTITY_AUTO_DISCOVERY === "false" ?
          `App is not signed: env CSC_IDENTITY_AUTO_DISCOVERY is set to false` :
          `App is not signed: cannot find valid ${isMas ? '"3rd Party Mac Developer Application" identity' : `"Developer ID Application" identity or custom non-Apple code signing certificate`}, see https://github.com/electron-userland/electron-builder/wiki/Code-Signing`
        if (isMas || this.platformSpecificBuildOptions.forceCodeSigning) {
          throw new Error(message)
        }
        else {
          warn(message)
          return
        }
      }
    }

As for the current logic in macPackager.ts, when provided with an identity string, it first try to get it as a "3rd Party Mac Developer Installer"/"Developer ID Installer"; If returns null, it will do an additional identity query for Darwin as 'Mac Developer'; If returns null again, it will decide to either throw an error or display a warning message depending on the build options(isMas || this.platformSpecificBuildOptions.forceCodeSigning);

So here in findIdentity() I don't see why it should throw an error when failed to get identity. It can just return string|null denoting whether it find the requested identity or not, and let macPackager.ts do the result checking part. findIdentity() should not throw error before every options are tried in macPackager.ts.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if this.platformSpecificBuildOptions.identity is specified explicitly, we must throw error. Currently, we will throw error in the macPackager only for mas. If check removed from findIdentity, here, in the macPackager, we must add corresponding check.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Get it, thanks

@develar
Copy link
Member

develar commented Jan 12, 2017

@ericzhangjx Thank you for investigation.

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

Successfully merging this pull request may close these issues.

2 participants