Code Monkey home page Code Monkey logo

gon's Introduction

Archived: I unfortunately no longer make active use of this project and haven't properly maintained it since early 2022. I welcome anyone to fork and take over this project.


gon - CLI and Go Library for macOS Notarization

gon is a simple, no-frills tool for signing and notarizing your CLI binaries for macOS. gon is available as a CLI that can be run manually or in automation pipelines. It is also available as a Go library for embedding in projects written in Go. gon can sign and notarize binaries written in any language.

Beginning with macOS Catalina (10.15), Apple is requiring all software distributed outside of the Mac App Store to be signed and notarized. Software that isn't properly signed or notarized will be shown an error message with the only actionable option being to "Move to Bin". The software cannot be run even from the command-line. The workarounds are painful for users. gon helps you automate the process of notarization.

Features

  • Code sign one or multiple files written in any language
  • Package signed files into a dmg or zip
  • Notarize packages and wait for the notarization to complete
  • Concurrent notarization for multiple output formats
  • Stapling notarization tickets to supported formats (dmg) so that Gatekeeper validation works offline.

See roadmap for features that we want to support but don't yet.

Example

The example below runs gon against itself to generate a zip and dmg.

gon Example

Installation

The easiest way to install gon is via Homebrew:

$ brew install mitchellh/gon/gon

You may also download the appropriate release for your platform from the releases page. These are all signed and notarized to run out of the box on macOS 10.15+.

You can also compile from source using Go 1.13 or later using standard go build. Please ensure that Go modules are enabled.

Usage

gon requires a configuration file that can be specified as a file path or passed in via stdin. The configuration specifies all the settings gon will use to sign and package your files.

gon must be run on a macOS machine with XCode 11.0 or later. Code signing, notarization, and packaging all require tools that are only available on macOS machines.

$ gon [flags] [CONFIG]

When executed, gon will sign, package, and notarize configured files into requested formats. gon will exit with a 0 exit code on success and any other value on failure.

Prerequisite: Acquiring a Developer ID Certificate

Before using gon, you must acquire a Developer ID Certificate. To do this, you can either do it via the web or via Xcode locally on a Mac. Using Xcode is easier if you already have it installed.

Via the web:

  1. Sign into developer.apple.com with valid Apple ID credentials. You may need to sign up for an Apple developer account.

  2. Navigate to the certificates page.

  3. Click the "+" icon, select "Developer ID Application" and follow the steps.

  4. After downloading the certificate, double-click to import it into your keychain. If you're building on a CI machine, every CI machine must have this certificate in their keychain.

Via Xcode:

  1. Open Xcode and go to Xcode => Preferences => Accounts

  2. Click the "+" in the bottom left and add your Apple ID if you haven't already.

  3. Select your Apple account and click "Manage Certificates" in the bottom right corner.

  4. Click "+" in the bottom left corner and click "Developer ID Application".

  5. Right-click the newly created cert in the list, click "export" and export the file as a p12-formatted certificate. Save this somewhere. You'll never be able to download it again.

To verify you did this correctly, you can inspect your keychain:

$ security find-identity -v
  1) 97E4A93EAA8BAC7A8FD2383BFA459D2898100E56 "Developer ID Application: Mitchell Hashimoto (GK79KXBF4F)"
     1 valid identities found

You should see one or more certificates and at least one should be your Developer ID Application certificate. The hexadecimal string prefix is the value you can use in your configuration file to specify the identity.

Configuration File

The configuration file can specify allow/deny lists of licenses for reports, license overrides for specific dependencies, and more. The configuration file format is HCL or JSON.

Example:

source = ["./terraform"]
bundle_id = "com.mitchellh.example.terraform"

apple_id {
  username = "[email protected]"
  password = "@env:AC_PASSWORD"
  provider = "UL304B4VGY"
}

sign {
  application_identity = "Developer ID Application: Mitchell Hashimoto"
}

dmg {
  output_path = "terraform.dmg"
  volume_name = "Terraform"
}

zip {
  output_path = "terraform.zip"
}
{
    "source" : ["./terraform"],
    "bundle_id" : "com.mitchellh.example.terraform",
    "apple_id": {
        "username" : "[email protected]",
        "password":  "@env:AC_PASSWORD",
        "provider":  "UL304B4VGY"
    },
    "sign" :{
        "application_identity" : "Developer ID Application: Mitchell Hashimoto"
    },
    "dmg" :{
        "output_path":  "terraform.dmg",
        "volume_name":  "Terraform"
    },
    "zip" :{
        "output_path" : "terraform.zip"
    }
}

Supported configurations:

  • source (array<string>) - A list of files to sign, package, and notarize. If you want to sign multiple files with different identities or into different packages, then you should invoke gon with separate configurations. This is optional if you're using the notarization-only mode with the notarize block.

  • bundle_id (string) - The bundle ID for your application. You should choose something unique for your application. You can also register these with Apple. This is optional if you're using the notarization-only mode with the notarize block.

  • apple_id - Settings related to the Apple ID to use for notarization.

    • username (string) - The Apple ID username, typically an email address. This will default to the AC_USERNAME environment variable if not set.

    • password (string) - The password for the associated Apple ID. This can be specified directly or using @keychain:<name> or @env:<name> to avoid putting the plaintext password directly in a configuration file. The @keychain:<name> syntax will load the password from the macOS Keychain with the given name. The @env:<name> syntax will load the password from the named environmental variable. If this value isn't set, we'll attempt to use the AC_PASSWORD environment variable as a default.

      NOTE: If you have 2FA enabled, the password must be an application password, not your normal apple id password. See Troubleshooting for details.

    • provider (string) - The App Store Connect provider when using multiple teams within App Store Connect. If this isn't set, we'll attempt to read the AC_PROVIDER environment variable as a default.

  • sign - Settings related to signing files.

    • application_identity (string) - The name or ID of the "Developer ID Application" certificate to use to sign applications. This accepts any valid value for the -s flag for the codesign binary on macOS. See man codesign for detailed documentation on accepted values.

    • entitlements_file (string optional) - The full path to a plist format .entitlements file, used for the --entitlements argument to codesign

  • dmg (optional) - Settings related to creating a disk image (dmg) as output. This will only be created if this is specified. The dmg will also have the notarization ticket stapled so that it can be verified offline and do not require internet to use.

    • output_path (string) - The path to create the zip archive. If this path already exists, it will be overwritten. All files in source will be copied into the root of the zip archive.

    • volume_name (string) - The name of the mounted dmg that shows up in finder, the mounted file path, etc.

  • zip (optional) - Settings related to creating a zip archive as output. A zip archive will only be created if this is specified. Note that zip archives don't support stapling, meaning that files within the notarized zip archive will require an internet connection to verify on first use.

    • output_path (string) - The path to create the zip archive. If this path already exists, it will be overwritten. All files in source will be copied into the root of the zip archive.

Notarization-only mode:

  • notarize (optional) - Settings for notarizing already built files. This is an alternative to using the source option. This option can be repeated to notarize multiple files.

    • path (string) - The path to the file to notarize. This must be one of Apple's supported file types for notarization: dmg, pkg, app, or zip.

    • bundle_id (string) - The bundle ID to use for this notarization. This is used instead of the top-level bundle_id (which controls the value for source-based runs).

    • staple (bool optional) - Controls if stapler staple should run if notarization succeeds. This should only be set for filetypes that support it (dmg, pkg, or app).

Notarization-Only Configuration

You can configure gon to notarize already-signed files. This is useful if you're integrating gon into an existing build pipeline that may already support creation of pkg, app, etc. files.

Because notarization requires the payload of packages to also be signed, this mode assumes that you have codesigned the payload as well as the package itself. gon will not sign your package in the notarize blocks. Please do not confuse this with when source is set and gon itself creates your packages, in which case it will also sign them.

You can use this in addition to specifying source as well. In this case, we will codesign & package the files specified in source and then notarize those results as well as those in notarize blocks.

Example in HCL and then the identical configuration in JSON:

notarize {
  path = "/path/to/terraform.pkg"
  bundle_id = "com.mitchellh.example.terraform"
  staple = true
}

apple_id {
  username = "[email protected]"
  password = "@env:AC_PASSWORD"
}
{
  "notarize": [{
    "path": "/path/to/terraform.pkg",
    "bundle_id": "com.mitchellh.example.terraform",
    "staple": true
  }],

  "apple_id": {
     "username": "[email protected]",
     "password": "@env:AC_PASSWORD"
  }
}

Note you may specify multiple notarize blocks to notarize multipel files concurrently.

Processing Time

The notarization process requires submitting your package(s) to Apple and waiting for them to scan them. Apple provides no public SLA as far as I can tell.

In developing gon and working with the notarization process, I've found the process to be fast on average (< 10 minutes) but in some cases notarization requests have been queued for an hour or more.

gon will output status updates as it goes, and will wait indefinitely for notarization to complete. If gon is interrupted, you can check the status of a request yourself using the request UUID that gon outputs after submission.

Using within Automation

gon is built to support running within automated environments such as CI pipelines. In this environment, you should use JSON configuration files with gon and the -log-json flag to get structured logging output.

Machine-Readable Output

gon always outputs human-readable output on stdout (including errors) and all log output on stderr. By specifying -log-json the log entries will be structured with JSON. You can process the stream of JSON using a tool such as jq or any scripting language to extract critical information such as the request UUID, status, and more.

When gon is run in an environment with no TTY, the human output will not be colored. This makes it friendlier for output logs.

Example:

$ gon -log-level=info -log-json ./config.hcl
...

Note you must specify both -log-level and -log-json. The -log-level flag enables logging in general. An info level is enough in automation environments to get all the information you'd want.

Prompts

On first-run may be prompted multiple times for passwords. If you click "Always Allow" then you will not be prompted again. These prompts are originating from Apple software that gon is subprocessing, and not from gon itself.

I do not currently know how to script the approvals, so the recommendation on build machines is to run gon manually once. If anyone finds a way to automate this please open an issue, let me know, and I'll update this README.

Usage with GoReleaser

GoReleaser is a popular full featured release automation tool for Go-based projects. Gon can be used with GoReleaser to augment the signing step to notarize your binaries as part of a GoReleaser pipeline.

Here is an example GoReleaser configuration to sign your binaries:

builds:
- binary: foo
  id: foo
  goos:
  - linux
  - windows
  goarch:
  - amd64
# notice that we need a separated build for the macos binary only:
- binary: foo
  id: foo-macos
  goos:
  - darwin
  goarch:
  - amd64
signs:
  - signature: "${artifact}.dmg"
    ids:
    - foo-macos # here we filter the macos only build id
    # you'll need to have gon on PATH
    cmd: gon
    # you can follow the gon docs to properly create the gon.hcl config file:
    # https://github.com/mitchellh/gon
    args:
    - gon.hcl
    artifacts: all

To learn more, see the GoReleaser documentation.

Go Library

Godoc

We also expose a supported API for signing, packaging, and notarizing files using the Go programming language. Please see the linked Go documentation for more details.

The libraries exposed are purposely lower level and separate out the sign, package, notarization, and stapling steps. This lets you integrate this functionality into any tooling easily vs. having an opinionated gon-CLI experience.

Troubleshooting

"We are unable to create an authentication session. (-22016)"

You likely have Apple 2FA enabled. You'll need to generate an application password and use that instead of your Apple ID password.

Roadmap

These are some things I'd love to see but aren't currently implemented.

  • Expose more DMG customization so you can set backgrounds, icons, etc.
    • The underlying script we use already supports this.
  • Support adding additional files to the zip, dmg packages
  • Support the creation of '.app' bundles for CLI applications

gon's People

Contributors

etter-tanium avatar evanphx avatar luisurr avatar maxfierke avatar megavoid avatar mitchellh avatar simonw avatar skyzyx avatar vrischmann avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

gon's Issues

warning Calling Bottle :unneeded is deprecated

hello,

The Homebrew bottle need some update since ":unneeded" is deprecated.

Error messages on update with brew :

Warning: Calling bottle :unneeded is deprecated! There is no replacement.
Please report this issue to the mitchellh/gon tap (not Homebrew/brew or Homebrew/core):
/usr/local/Homebrew/Library/Taps/mitchellh/homebrew-gon/gon.rb:6

Thanks

Signing with an invalid developer ID cert returns success

Issue: When I provide an invalid developer ID cert (oops), gon successfully completes and doesn't return an error. The log file shows a warning with the following under issues:

"issues": [
    {
      "severity": "warning",
      "code": null,
      "path": "terraform",
      "message": "The binary is not signed with a valid Developer ID certificate.",
      "docUrl": null,
      "architecture": "x86_64"
    }
  ]

IMO this is a fatal error, as the resulting executables can't be opened on OSX 10.15.

Solution: Exit gon and return an error if this 'warning' appears in the log file.

Check pre-requisites (XCode) upfront programatically

I appreciate that the Readme says I need XCode 11.0+ installed, but gon should probably fail early and gracefully to tell me this if for some reason I missed that instruction or I just switched to a freshly installed MacOS which just doesn't have XCode installed by default.

Currently it allows me to get through a few steps successfully and then fails with an error that may not be immediately understood and attributed to XCode by someone who doesn't know Apple Dev ecosystem.

   • signing artifacts
      • signing                   cmd=[gon .gon.hcl]
      • ==> ✏️  Signing files...
 cmd=gon
      •     Code signing successful
==> 📦  Creating Zip archive...
 cmd=gon
      •     Zip archive created with signed files
==> 📦  Creating dmg...
    This will open Finder windows momentarily.
 cmd=gon
      •     Dmg file created: ./dist/gon_macos.dmg
    Signing dmg...
 cmd=gon
      •     Dmg created and signed
==> 🍎  Notarizing...
    Files will be notarized concurrently to optimize queue wait
 cmd=gon
      •     Path: ./dist/gon_macos.zip
    Path: ./dist/gon_macos.dmg
 cmd=gon
      •     [gon_macos.dmg] Submitting file for notarization...
 cmd=gon
      •     [gon_macos.dmg] Error notarizing
 cmd=gon
      •     [gon_macos.zip] Submitting file for notarization...
 cmd=gon
      •     [gon_macos.zip] Error notarizing
 cmd=gon
      •
❗️ Error notarizing:

2 errors occurred:
	* error submitting for notarization:

xcrun: error: unable to find utility "altool", not a developer tool or in PATH

	* error submitting for notarization:

xcrun: error: unable to find utility "altool", not a developer tool or in PATH

Related: I was actually able to notarize a binary with XCode 10.3 on MacOS 10.14.6:

Xcode 10.3
Build version 10G8

I think what gon could check is roughly the following:

$ /usr/bin/xcodebuild -version
xcode-select: error: tool 'xcodebuild' requires Xcode, but active developer directory '/Library/Developer/CommandLineTools' is a command line tools instance
$ echo $?
1

and also check whether license was agreed to

$ xcodebuild --help


Agreeing to the Xcode/iOS license requires admin privileges, please run “sudo xcodebuild -license” and then retry this command.


$ echo $?
69

Zip option fails notarization

Hi,

first, let me thank you for providing this great tool!

I encountered an issue with app notarization when providing a zip file:

{
  "source" : ["target/EPUB-Checker.app"],
  "bundle_id" : "de.paginagmbh.epubchecker",
  "apple_id": {
    "username" : "",
    "password":  "",
    "provider": ""
  },
  "sign" :{
      "application_identity" : ""
  },
  "zip" :{
    "output_path":  "target/EPUB-Checker.zip"
  }
}

The notarization fails with the following error:

❗️ Error notarizing:

1 error occurred:
	* error for path "EPUB-Checker.zip": Package EPUB-Checker.zip has no signed executables or bundles. No tickets can be generated.

Indeed, the ZIP file does not contain the App bundle. The ZIP file contains the Contents folder on top level, but is missing the app bundle folder...

Best regards,
Tobias

Unable to upload your app for notarization. (-1011)

I hit this and couldn't find many mentions of this exact error code on the internet. Fortunately, I solved it so I'm just posting an issue to benefit others who may be searching for the same code.

From what I could tell, this happens because multi-device authentication is enabled for my account, so logins via my primary email+password pair typically require a secondary device (iPhone etc) to validate the authentication.

Obviously machine authentication cannot do this and it doesn't make sense for a CI pipeline anyway. The solution is actually mentioned in the docs but the error code is different (maybe outdated? Apple doesn't document this stuff...)

What you want is an application specific password in place of AC_PASSWORD which is done via this button:

image

On the page https://appleid.apple.com/account/manage

Hope that helps someone spend fewer hours figuring it out than I did!

Sha256 are not the same and fails notorisation.

I am using an application specific password due to having 2fa

The cli is excellent and tells you how to fix things even. Nice handholding.

But on a users machine the sha256 is not the same as in my dev machine. And it fails to notorise.

Any ideas ?

README: update goreleaser example config

The current README contents illustrate using gon with goreleaser’s sign option.

However, goreleaser has introduced build hooks almost a year ago, and seems to recommend using those over sign: goreleaser/goreleaser@bda76d6

In fact, when using the gon README’s instructions, I run into an error:

   ⨯ release failed after 168.61s error=github/gitlab/gitea releases: failed to publish artifacts: failed to upload checksums.txt.dmg after 1 tries: open dist/checksums.txt.dmg: no such file or directory

Could you update the README with a known-working config please?

error signing: code object is not signed at all

I am not sure that it is a big, and I rather suppose that I am doing something wrong, but maybe you could help me with this.

While signing a binary, I get the following error:

code object is not signed at all

I signed some other binaries, and it worked perfectly well, so I suppose the problem is with this binary only.
It is an electron app.

gon reports notarizing failure even though Apple successfully notarized

Our workflow can be found here. It worked fine in the past.

2021-05-27T23:33:44.9183580Z     [bebopc.zip] File notarized!
2021-05-27T23:33:44.9276730Z 
2021-05-27T23:33:44.9332980Z ❗️ Error notarizing:
2021-05-27T23:33:44.9358450Z 
2021-05-27T23:33:44.9367080Z 1 error occurred:
2021-05-27T23:33:44.9368930Z 	* package is invalid. To learn more download the logs at the URL: 
2021-05-27T23:33:44.9372010Z 
2021-05-27T23:33:44.9400060Z 
2021-05-27T23:33:44.9417640Z ##[error]Process completed with exit code 1.
2021-05-27T23:33:44.9839920Z Cleaning up orphan processes
2021-05-27T23:33:45.2954010Z Terminate orphan process: pid (1240) (dotnet)

Info.plist Support?

I have used gon to do signing and notarization for a command line tool. It works correctly when the binary is invoked from the command line (i.e., inside the Terminal application). If a user tries to invoke the tool inside Finder, he sees the same security warning as if the binary where not signed.

After doing some research, I am wondering if the lack of an embedded Info.plist file is contributing to this behavior. Has anyone else tried to ship a signed command line tool and encounter this behavior?

The gon.hcl file contains a bundle_id, but it does not include a Bundle name. Is gon including these (along with a Bundle Version)?

Not yet accepted PLA results in error: failed to decode notarization submission output: plist: error parsing text property list: missing = in dictionary at line 1 character 1

I’m using gon via goreleaser and got the following output:

      • running hook              hook=gon gon.hcl
      • ==> ✏️  Signing files...
 cmd=[gon gon.hcl]
      •     Code signing successful
==> 📦  Creating dmg...
 cmd=[gon gon.hcl]
      •     This will open Finder windows momentarily.
 cmd=[gon gon.hcl]
      •     Dmg file created: ./dist/qrbill_api_Darwin_x86_64.dmg
    Signing dmg...
 cmd=[gon gon.hcl]
      •     Dmg created and signed
==> 🍎  Notarizing...
 cmd=[gon gon.hcl]
      •     Path: ./dist/qrbill_api_Darwin_x86_64.dmg
    Submitting file for notarization...
 cmd=[gon gon.hcl]
      •     Error notarizing
     cmd=[gon gon.hcl]
      • 
❗️ Error notarizing:

1 error occurred:
	* failed to decode notarization submission output: plist: error parsing text property list: missing = in dictionary at line 1 character 1

The solution was to log into https://developer.apple.com/account/ in a browser and agree to the updated PLA terms.

I was able to diagnose this in Xcode -> Accounts -> Manage Certificates, where Xcode showed an error message about having to agree to the updated PLA.

Perhaps gon could show a similar error message in this situation?

Manual keychain approvals — solved

Hi there! The README asks for an issue to be submitted if we solve the issue of macOS Keychain requiring manual approval while running gon. Here's how we solved it at Anchore.

In order for a keychain item (e.g. the code signing key) to be accessed immediately without prompting the user, you need to set a "partition list" for the keychain item. According to man security (for the subcommand set-key-partition-list):

[...] The "partition list" is an extra parameter in the ACL which limits access to the key based on an application's code signature. You must present the keychain's password to change a partition list. If you'd like to run /usr/bin/codesign with the key, "apple:" must be an element of the partition list.

So, if users run security set-key-partition-list ... prior to running gon, gon/codesign can use the signing key immediately without requiring a human's approval.

There's an important catch:

You must present the keychain's password to change a partition list.

We found that most CI tools with macOS environments don't give you the password to the running user's default keychain.

We solved this by creating a brand new keychain on the fly, for the sake of being in control of the keychain's password the whole time. This keychain can be totally ephemeral, and its password can be randomly generated at the last minute.

Hope this helps. Let me know if you have any questions.

Failed to sign the app through Ansible (SSH)

Hi,

I am trying to use gon to sign my app and generate dmg file through Ansible (SSH) but it keeps failing.
It works perfectly fine if I run it on Terminal on my local machine, however I got this error message on my Ansible's controller.
Sorry if I'm being nonsense or missing any information.

The error message is the following:

{
    "changed": true,
    "cmd":
    [
        "./gon",
        "sign.json"
    ],
    "delta": "0:00:00.051501",
    "end": "2022-05-17 17:50:43.235146",
    "msg": "non-zero return code",
    "rc": 1,
    "start": "2022-05-17 17:50:43.183645",
    "stderr": "",
    "stderr_lines":
    [],
    "stdout": "==> ✏️  Signing files...\n❗️ Error signing files:\n\nerror signing:\n\n../xxx.app/Contents/PlugIns/libsqlite3.so: replacing existing signature\n../xxx.app/Contents/PlugIns/libsqlite3.so: errSecInternalComponent",
    "stdout_lines":
    [
        "==> ✏️  Signing files...",
        "❗️ Error signing files:",
        "",
        "error signing:",
        "",
        "../xxx.app/Contents/PlugIns/libsqlite3.so: replacing existing signature",
        "../xxx.app/Contents/PlugIns/libsqlite3.so: errSecInternalComponent"
    ]
}

Support use of apiKey/apiIssuer instead of username/password

It would be nice if gon supported the use of apiKey/apiIssuer as an alternative to using username and password for notification.

From the help text of altool:

> xcrun altool --help
Copyright (c) 2009-2019, Apple Inc. Version 4.00.1181

Usage: altool --validate-app -f <file> -t <platform> -u <username> {[-p <password>] | --apiKey <api_key> --apiIssuer <issuer_id>}
       altool --upload-app -f <file> -t <platform> -u <username> {[-p <password>] | --apiKey <api_key> --apiIssuer <issuer_id>}
       altool --notarize-app -f <file> --primary-bundle-id <bundle_id> -u <username> {[-p <password>] | --apiKey <api_key> --apiIssuer <issuer_id>} [--asc-provider <provider_shortname>]
       altool --notarization-info <uuid> -u <username> {[-p <password>] | --apiKey <api_key> --apiIssuer <issuer_id>}
       altool --notarization-history <page> -u <username> {[-p <password>] | --apiKey <api_key> --apiIssuer <issuer_id>} [--asc-provider <provider_shortname>]
       altool --list-apps -u <username> {[-p <password>] | --apiKey <api_key> --apiIssuer <issuer_id>}
       altool --store-password-in-keychain-item <name_for_keychain_item> -u <username> -p <password>

Authentication: Most commands require authorization.
                There are two methods available: user name with password, and apiKey with apiIssuer.

                -u, --username <username> Username. Required to connect for validation, upload, and notarization.
                -p, --password <password> Password. Required if username specified and apiKey/apiIssuer are not.
                                          If this argument is not supplied on the command line, it will be read from stdin.
                                          Alternatively to entering <password> in plaintext, it may also be specified using a '@keychain:'
                                          or '@env:' prefix followed by a keychain password item name or environment variable name.
                                          Example: '-p @keychain:<name>' uses the password stored in the keychain password item named <name>.
                                                                         You can create and update keychain items with the
                                                                         --store-password-in-keychain-item command.
                                          Example: '-p @env:<variable>'  uses the value in the environment variable named <variable>

                --apiKey <api_key>        apiKey. Required for JWT authentication while using validation, upload, and notarization.
                                          This option will search the following directories in sequence for a private key file
                                          with the name of 'AuthKey_<api_key>.p8':  './private_keys', '~/private_keys', '~/.private_keys',
                                          and '~/.appstoreconnect/private_keys'.
                --apiIssuer <issuer_id>   Issuer ID. Required if --apiKey is specified.

having notarize declared in config uploads/notarizes zip twice

here's my config file:

source = ["./example"]
bundle_id = "com.example.app"

apple_id {
  username = "[email protected]"
  password = "@env:AC_PASSWORD"
}

sign {
  application_identity = "Developer ID Application: Example inc."
}

zip {
  output_path = "./test.zip"
}

notarize {
  path = "./test.zip"
  bundle_id = "com.example.app"
  staple = true
}

that used to work and all of a sudden, it's uploading test.zip twice.

==> ✏️  Signing files...
    Code signing successful
==> 📦  Creating Zip archive...
    Zip archive created with signed files
==> 🍎  Notarizing...
    Files will be notarized concurrently to optimize queue wait
    Path: ./test.zip
    Path: ./test.zip
    [test.zip] Submitting file for notarization...

commenting the notarize block fixes the issue. that's kinda strange. running version 0.2.3. issue #44 is a bit similar. but our app has 2 dynamic ldflags used that makes each binary unique.

dmg file

If i have a dmg file, do I have to run gon on all the executable files inside and the dmg file?

Throw a custom exit code for (or "properly handle") ITMS-90732 error

ERROR ITMS-90732 is what the notarization service throws when you attempt to re-notarize a package that has already been notarized. When running gon in a CI environment, is can happen with some frequency that some non-gon related part of the job (e.g. uploading to your artifact store) fails and you need to retry.

In the short term, it would be useful if gon was able to detect ITMS-90732 errors and exit with a code other than 1. That way we can (in theory) detect this exit code in our caller scripts and choose not to fail our notarization jobs.

In the longer term, it would be amazing if gon could "pick up" the notarization and exit "as normal" depending on the success or failure of the notarization.

Sample gon output

{
  "@level": "info",
  "@message": "notarization submission complete",
  "@module": "notarize",
  "@timestamp": "2021-05-05T06:30:24.065847-07:00",
  "err": "exit status 1",
  "output": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<!DOCTYPE plist PUBLIC \"-//Apple//DTD PLIST 1.0//EN\" \"http://www.apple.com/DTDs/PropertyList-1.0.dtd\">\n<plist version=\"1.0\">\n<dict>\n\t<key>os-version</key>\n\t<string>10.15.7</string>\n\t<key>product-errors</key>\n\t<array>\n\t\t<dict>\n\t\t\t<key>code</key>\n\t\t\t<integer>-18000</integer>\n\t\t\t<key>message</key>\n\t\t\t<string>ERROR ITMS-90732: \"The software asset has already been uploaded. The upload ID is bcaa06a2-11a1-4821-8340-80a35eae35a2\" at SoftwareAssets/EnigmaSoftwareAsset</string>\n\t\t\t<key>userInfo</key>\n\t\t\t<dict>\n\t\t\t\t<key>NSLocalizedDescription</key>\n\t\t\t\t<string>ERROR ITMS-90732: \"The software asset has already been uploaded. The upload ID is bcaa06a2-11a1-4821-8340-80a35eae35a2\" at SoftwareAssets/EnigmaSoftwareAsset</string>\n\t\t\t\t<key>NSLocalizedFailureReason</key>\n\t\t\t\t<string>ERROR ITMS-90732: \"The software asset has already been uploaded. The upload ID is bcaa06a2-11a1-4821-8340-80a35eae35a2\" at SoftwareAssets/EnigmaSoftwareAsset</string>\n\t\t\t\t<key>NSLocalizedRecoverySuggestion</key>\n\t\t\t\t<string>ERROR ITMS-90732: \"The software asset has already been uploaded. The upload ID is bcaa06a2-11a1-4821-8340-80a35eae35a2\" at SoftwareAssets/EnigmaSoftwareAsset</string>\n\t\t\t</dict>\n\t\t</dict>\n\t</array>\n\t<key>tool-path</key>\n\t<string>/Applications/Xcode.app/Contents/SharedFrameworks/ContentDeliveryServices.framework/Versions/A/Frameworks/AppStoreService.framework</string>\n\t<key>tool-version</key>\n\t<string>4.029.1194</string>\n</dict>\n</plist>\n\n"
 }

bless: The 'openfolder' is not supported on Apple Silicon devices.

[david@ajn-im1]00:36:17|~/go/src/github.com/Notifiarr/notifiarr$ /Users/david/go/bin/gon gon.json
==> ✏️  Signing files...
    Code signing successful
==> 📦  Creating dmg...
    This will open Finder windows momentarily.
❗️ Error creating dmg:

error creating dmg:

Creating disk image...
created: /Users/david/go/src/github.com/Notifiarr/notifiarr/rw.notifiarr.dmg
Mounting disk image...
Unmounting disk image...
Mount directory: /Volumes/Notifiarr
Device name:     /dev/disk8
Copying custom files...
./notifiarr
Running Applescript: /usr/bin/osascript "/var/folders/ks/dgpqf8ld1qg5871wcc2fqw340000gn/T/createdmg.tmp.XXXXXXXXXX.Dzo8JSw2" "Notifiarr"
waited 1 seconds for .DS_STORE to be created.
Done running the applescript...
Fixing permissions...
Done fixing permissions.
Blessing started
bless: The 'openfolder' is not supported on Apple Silicon devices.

iMac M1 running macOS 12.4.
Installed gon by running: go install github.com/mitchellh/gon/cmd/gon@latest
Let me know if I can provide more info. This is the first time I've used this app.

Avoiding password prompts

First off, thanks for this tool. Much better than the signing/notarizing scripts I've been hacking on.

In that work, I may have stumbled on an approach that solves the prompt issue with some clues from this SO post. Specifically, creating a temp keychain, importing the signing identities into that and then referencing the temp keychain when invoking codesign, productbuild, etc. Something like

security create-keychain -p insecure ci-keys
security set-keychain-settings ci-keys # remove the auto-lock timeout
security unlock-keychain -p insecure ci-keys
# -P $PASSWORD if the identity files are password protected
security import dev-id-app.p12 -k ci-keys -P "" -A # or -T /usr/bin/codesign
security import dev-id-pkg.p12 -k ci-keys -P "" -A # or -T /usr/bin/productbuild -T /usr/bin/productsign
codesign -s $dev-id-app-SHA1 --keychain ci-keys ...
productbuild --sign $dev-id-pkg-SHA1 --keychain ci-keys ... 

One thing to note, I had to import the original .cer file (from the web download) into the keychain via Finder and re-export it as a .p12. When I tried security import dev-id-app.cer it didn't import as an "identity" which the .p12 version does.

I also haven't verified on a fresh OS yet and have previously clicked "Always Allow" for the default keychain. There are notes in the man pages about embedding intermediate certs when signing that could be looked up in the standard keychain which may be problematic still. Although, I suspect those could be added to the temp keychain if needed as well.

Auto code sign notary errors feature

Can you add a feature that can go back and code sign files that come back with error after its submitted to apple notary service. This way we don't have to go back and do it all manually

No such environment variable for key: 'AC_PASSWORD' (-1005)

I'm following the excellent configuration advice in the README to create my first notarized package. Thank goodness for gon! Apple does not make this process easy to figure out for first-time developers.

I'm stuck with the following errors shown below though with regards to notarizing.

I see that Issue #10 appears to address this, but I can't quite figure out how to get gon to fall back to asking for the AC_PASSWORD.

Honestly, I'm not sure what the AC_PASSORD is. I found this article about setting an AC_PASSWORD in the keychain, but I'm a little nervous to do this; I'm not sure what I'm setting or how to undo it.

What am I missing?

  $ gon hello_world.hcl
==> ✏️  Signing files...
    Code signing successful
==> 📦  Creating Zip archive...
    Zip archive created with signed files
==> 📦  Creating dmg...
    Dmg created and signed
==> 🍎  Notarizing...
    Files will be notarized concurrently to optimize queue wait
    Path: hello_world.zip
    Path: hello_world.dmg
    [hello_world.dmg] Submitting file for notarization...
    [hello_world.dmg] Error notarizing
    [hello_world.zip] Submitting file for notarization...
    [hello_world.zip] Error notarizing

❗️ Error notarizing:

2 errors occurred:
	* 1 error occurred:
	* No such environment variable for key: 'AC_PASSWORD' (-1005)


	* 1 error occurred:
	* No such environment variable for key: 'AC_PASSWORD' (-1005)

For completeness here's my .hcl configuration.

source = ["./dist/hello_world"]
bundle_id = "com.txoof.helloworld"

apple_id {
  username = "[email protected]"
  password = "@env:AC_PASSWORD"
}

sign {
  application_identity = "Developer ID Application: Aaron Ciuffo"
}

dmg {
  output_path = "hello_world.dmg"
  volume_name = "Hello"
}

zip {
  output_path = "hello_world.zip"
}

Embed provisioning profile

Right now if a binary needs restricted entitlements then a host should have provisioning profile installed or the "app" should embed it. Otherwise error like the following will occur and macOS will kill the binary:

taskgated-helper	Disallowing tart because no eligible provisioning profiles found
mac_vnode_check_signature: tart: code signature validation failed fatally: When validating tart:
  Code has restricted entitlements, but the validation of its code signature failed.

I found this piece of documentation:

Some macOS products, like daemons and command-line tools, ship as a standalone executable. A standalone executable can’t claim a restricted entitlement because there’s no place to embed the provisioning profile that authorizes that claim. If your standalone executable needs to do this, wrap it in an app-like structure. For an example of this, see Signing a Daemon with a Restricted Entitlement.

If your standalone executable needs to do this, wrap it in an app-like structure. part is very concerning for just distributing binaries.

I haven't yet figured out how to embed provisioning profile with a binary so decided to create this issue/feature request to surface the use case and see if someone experienced it.

brew tap mitchellh/gon has stopped working

I think this worked a couple of weeks ago, but I had a hardware problem and had to reinstall after repair. Now I get:

$ brew tap mitchellh/gon
==> Tapping mitchellh/gon
Cloning into '/usr/local/Homebrew/Library/Taps/mitchellh/homebrew-gon'...
remote: Enumerating objects: 12, done.
remote: Counting objects: 100% (12/12), done.
remote: Compressing objects: 100% (9/9), done.
remote: Total 12 (delta 2), reused 10 (delta 1), pack-reused 0
Receiving objects: 100% (12/12), done.
Resolving deltas: 100% (2/2), done.
Error: Invalid formula: /usr/local/Homebrew/Library/Taps/mitchellh/homebrew-gon/gon.rb
gon: Calling bottle :unneeded is disabled! There is no replacement.
Please report this issue to the mitchellh/gon tap (not Homebrew/brew or Homebrew/core):
  /usr/local/Homebrew/Library/Taps/mitchellh/homebrew-gon/gon.rb:6

Error: Cannot tap mitchellh/gon: invalid syntax in tap!

FR: sign Windows binaries

It would be a vast simplification for our release process if gon can sign windows binaries and packages.
At this point, I do not understand the complexity of this request. I hope the community and authors can share some thoughts.

getting problem with notarize

Error notarizing:

1 error occurred:
* 2 errors occurred:
* Unable to upload your app for notarization. (-1011)
* Unable to upload your app for notarization. (-1027)

Error signing files. Please help

Error signing files:

error signing:

./EcammLiveMidiController.app: code object is not signed at all
In subcomponent: /Users/admin/Documents/elmcsign/EcammLiveMidiController.app/Contents/Frameworks/Electron Framework.framework

notarize: Failed to detect code 1519

On a CI build today I hit a case where error 1519 wasn't detected and ignored.

==> 🍎  Notarizing...
    Path: **** 
    Submitting file for notarization...
    Submitted. Request UUID: ******
    Waiting for results from Apple. This can take minutes to hours.
    Error notarizing
  
❗️ Error notarizing:
 
1 error occurred:
 	* 1 error occurred:
	* Could not find the RequestUUID. (1519)

Looking at the code nothing obvious jumps out as to what went wrong. Unless there's some failure path where it didn't get wrapped in an Errors object so the type conversion failed. This is on version 0.2.3.

Identity of the developer cannot be confirmed (despite successful notarization)

Maybe I'm missing something here but I added two binaries in the config, it created a dmg and notarized it successfully.

But upon downloading the opening the file, macOS still throws "Identity of the developer cannot be confirmed" error.

Config File

{
  "source": [
    "./macbinaries/binary_amd64",
    "./macbinaries/binary_arm64"
  ],
  "bundle_id": "my.bundle.id",
  "apple_id": {},
  "sign": {
    "application_identity": "Developer ID Application: Company Name (XXXXXXX)"
  },
  "dmg": {
    "output_path": "macbinaries/final.dmg",
    "volume_name": "My Volume"
  },
  "zip": {
    "output_path": "macbinaries/final.zip"
  }
}

Gon Logs

Run gon -log-level=info -log-json notarize.json
{"@level":"info","@message":"executing codesigning","@module":"sign","@timestamp":"2021-07-09T04:49:02.539975Z","command_args":["codesign","-s","Developer ID Application: InstaSafe Technologies Private Limited (9HQMLR4Y69)","-f","-v","--timestamp","--options","runtime","./macbinaries/binary_amd64","./macbinaries/binary_arm64"],"command_path":"/usr/bin/codesign","files":["./macbinaries/binary_amd64","./macbinaries/binary_arm64"]}
==> ✏️  Signing files...
{"@level":"info","@message":"codesigning complete","@module":"sign","@timestamp":"2021-07-09T04:49:04.183436Z","output":"./macbinaries/binary_amd64: signed Mach-O thin (x86_64) [binary_amd64]\n./macbinaries/binary_arm64: replacing existing signature\n./macbinaries/binary_arm64: signed Mach-O thin (arm64) [binary_arm64]\n"}
    Code signing successful
==> 📦  Creating Zip archive...
{"@level":"info","@message":"executing create-dmg for dmg creation","@module":"dmg","@timestamp":"2021-07-09T04:49:05.513820Z","command_args":["create-dmg","--volname","My Volume","--add-file","binary_amd64","./macbinaries/binary_amd64","0","0","--add-file","binary_arm64","./macbinaries/binary_arm64","0","0","macbinaries/final.dmg","/var/folders/24/8k48jl6d249_n_qfxwsl6xvm0000gn/T/gon655744049"],"command_path":"/var/folders/24/8k48jl6d249_n_qfxwsl6xvm0000gn/T/createdmg162274202/create-dmg","output_path":"macbinaries/final.dmg"}
    Zip archive created with signed files
==> 📦  Creating dmg...
    This will open Finder windows momentarily.
{"@level":"info","@message":"dmg creation complete","@module":"dmg","@timestamp":"2021-07-09T04:49:27.070153Z","output":"Creating disk image...\ncreated: /Users/runner/work/Go.Tunnel.Pipeline/Go.Tunnel.Pipeline/macbinaries/rw.final.dmg\nMounting disk image...\nUnmounting disk image...\nMount directory: /Volumes/My Volume\nDevice name:     /dev/disk2\nCopying custom files...\n./macbinaries/binary_amd64\n./macbinaries/binary_arm64\nRunning Applescript: /usr/bin/osascript \"/var/folders/24/8k48jl6d249_n_qfxwsl6xvm0000gn/T/createdmg.tmp.XXXXXXXXXX.cWogccRx\" \"My Volume\"\nwaited 1 seconds for .DS_STORE to be created.\nDone running the applescript...\nFixing permissions...\nDone fixing permissions.\nBlessing started\nBlessing finished\nUnmounting disk image...\n\"disk2\" ejected.\nCompressing disk image...\nPreparing imaging engine…\nReading Protective Master Boot Record (MBR : 0)…\n   (CRC32 $ECB7D5FB: Protective Master Boot Record (MBR : 0))\nReading GPT Header (Primary GPT Header : 1)…\n   (CRC32 $63C3205F: GPT Header (Primary GPT Header : 1))\nReading GPT Partition Data (Primary GPT Table : 2)…\n   (CRC32 $43405599: GPT Partition Data (Primary GPT Table : 2))\nReading  (Apple_Free : 3)…\n   (CRC32 $00000000:  (Apple_Free : 3))\nReading disk image (Apple_HFS : 4)…\n   (CRC32 $B50751FD: disk image (Apple_HFS : 4))\nReading  (Apple_Free : 5)…\n   (CRC32 $00000000:  (Apple_Free : 5))\nReading GPT Partition Data (Backup GPT Table : 6)…\n   (CRC32 $43405599: GPT Partition Data (Backup GPT Table : 6))\nReading GPT Header (Backup GPT Header : 7)…\n   (CRC32 $A0B1B65D: GPT Header (Backup GPT Header : 7))\nAdding resources…\nElapsed Time:  2.645s\nFile size: 7803469 bytes, Checksum: CRC32 $8B860E32\nSectors processed: 77904, 31212 compressed\nSpeed: 5.8Mbytes/sec\nSavings: 80.4%\ncreated: /Users/runner/work/Go.Tunnel.Pipeline/Go.Tunnel.Pipeline/macbinaries/final.dmg\nhdiutil does not support internet-enable. Note it was removed in macOS 10.15.\nDisk image done\n"}
    Dmg file created: macbinaries/final.dmg
{"@level":"info","@message":"executing codesigning","@module":"dmg","@timestamp":"2021-07-09T04:49:27.071756Z","command_args":["codesign","-s","Developer ID Application: InstaSafe Technologies Private Limited (9HQMLR4Y69)","-f","-v","--timestamp","--options","runtime","macbinaries/final.dmg"],"command_path":"/usr/bin/codesign","files":["macbinaries/final.dmg"]}
    Signing dmg...
{"@level":"info","@message":"codesigning complete","@module":"dmg","@timestamp":"2021-07-09T04:49:27.224168Z","output":"macbinaries/final.dmg: signed  []\n"}
    Dmg created and signed
{"@level":"info","@message":"submitting file for notarization","@module":"notarize","@timestamp":"2021-07-09T04:49:27.224782Z","command_args":["xcrun","altool","--notarize-app","--primary-bundle-id","my.bundle.id","-u","***","-p","@env:AC_PASSWORD","-f","macbinaries/final.dmg","--output-format","xml"],"command_path":"/usr/bin/xcrun","file":"macbinaries/final.dmg"}
==> 🍎  Notarizing...
    Files will be notarized concurrently to optimize queue wait
    Path: macbinaries/final.zip
    Path: macbinaries/final.dmg
    [final.dmg] Submitting file for notarization...
{"@level":"info","@message":"notarization submission complete","@module":"notarize","@timestamp":"2021-07-09T04:49:47.291216Z","err":null,"output":"\u003c?xml version=\"1.0\" encoding=\"UTF-8\"?\u003e\n\u003c!DOCTYPE plist PUBLIC \"-//Apple//DTD PLIST 1.0//EN\" \"http://www.apple.com/DTDs/PropertyList-1.0.dtd\"\u003e\n\u003cplist version=\"1.0\"\u003e\n\u003cdict\u003e\n\t\u003ckey\u003enotarization-upload\u003c/key\u003e\n\t\u003cdict\u003e\n\t\t\u003ckey\u003eRequestUUID\u003c/key\u003e\n\t\t\u003cstring\u003e6900e729-981d-4f54-b5cb-57b42a0ff7f0\u003c/string\u003e\n\t\u003c/dict\u003e\n\t\u003ckey\u003eos-version\u003c/key\u003e\n\t\u003cstring\u003e10.15.7\u003c/string\u003e\n\t\u003ckey\u003esuccess-message\u003c/key\u003e\n\t\u003cstring\u003eNo errors uploading 'macbinaries/final.dmg'.\u003c/string\u003e\n\t\u003ckey\u003etool-path\u003c/key\u003e\n\t\u003cstring\u003e/Applications/Xcode_12.4.app/Contents/SharedFrameworks/ContentDeliveryServices.framework/Versions/A/Frameworks/AppStoreService.framework\u003c/string\u003e\n\t\u003ckey\u003etool-version\u003c/key\u003e\n\t\u003cstring\u003e4.029.1194\u003c/string\u003e\n\u003c/dict\u003e\n\u003c/plist\u003e\n\n"}
    [final.dmg] Submitted. Request UUID: 6900e729-981d-4f54-b5cb-57b42a0ff7f0
{"@level":"info","@message":"notarization request submitted","@module":"notarize","@timestamp":"2021-07-09T04:49:47.292044Z","request_id":"6900e729-981d-4f54-b5cb-57b42a0ff7f0"}
    [final.dmg] Waiting for results from Apple. This can take minutes to hours.
{"@level":"info","@message":"submitting file for notarization","@module":"notarize","@timestamp":"2021-07-09T04:49:47.292329Z","command_args":["xcrun","altool","--notarize-app","--primary-bundle-id","my.bundle.id","-u","***","-p","@env:AC_PASSWORD","-f","macbinaries/final.zip","--output-format","xml"],"command_path":"/usr/bin/xcrun","file":"macbinaries/final.zip"}
    [final.zip] Submitting file for notarization...
{"@level":"info","@message":"requesting notarization info","@module":"notarize","@timestamp":"2021-07-09T04:49:57.386890Z","command_args":["xcrun","altool","--notarization-info","6900e729-981d-4f54-b5cb-57b42a0ff7f0","-u","***","-p","@env:AC_PASSWORD","--output-format","xml"],"command_path":"/usr/bin/xcrun","uuid":"6900e729-981d-4f54-b5cb-57b42a0ff7f0"}
{"@level":"info","@message":"notarization info command finished","@module":"notarize","@timestamp":"2021-07-09T04:49:58.452289Z","err":null,"output":"\u003c?xml version=\"1.0\" encoding=\"UTF-8\"?\u003e\n\u003c!DOCTYPE plist PUBLIC \"-//Apple//DTD PLIST 1.0//EN\" \"http://www.apple.com/DTDs/PropertyList-1.0.dtd\"\u003e\n\u003cplist version=\"1.0\"\u003e\n\u003cdict\u003e\n\t\u003ckey\u003enotarization-info\u003c/key\u003e\n\t\u003cdict\u003e\n\t\t\u003ckey\u003eDate\u003c/key\u003e\n\t\t\u003cdate\u003e2021-07-09T04:49:48Z\u003c/date\u003e\n\t\t\u003ckey\u003eRequestUUID\u003c/key\u003e\n\t\t\u003cstring\u003e6900e729-981d-4f54-b5cb-57b42a0ff7f0\u003c/string\u003e\n\t\t\u003ckey\u003eStatus\u003c/key\u003e\n\t\t\u003cstring\u003ein progress\u003c/string\u003e\n\t\u003c/dict\u003e\n\t\u003ckey\u003eos-version\u003c/key\u003e\n\t\u003cstring\u003e10.15.7\u003c/string\u003e\n\t\u003ckey\u003esuccess-message\u003c/key\u003e\n\t\u003cstring\u003eNo errors getting notarization info.\u003c/string\u003e\n\t\u003ckey\u003etool-path\u003c/key\u003e\n\t\u003cstring\u003e/Applications/Xcode_12.4.app/Contents/SharedFrameworks/ContentDeliveryServices.framework/Versions/A/Frameworks/AppStoreService.framework\u003c/string\u003e\n\t\u003ckey\u003etool-version\u003c/key\u003e\n\t\u003cstring\u003e4.029.1194\u003c/string\u003e\n\u003c/dict\u003e\n\u003c/plist\u003e\n\n"}
{"@level":"info","@message":"notarization info","@module":"notarize","@timestamp":"2021-07-09T04:49:58.452556Z","info":{"RequestUUID":"6900e729-981d-4f54-b5cb-57b42a0ff7f0","Date":"2021-07-09T04:49:48Z","Hash":"","LogFileURL":"","Status":"in progress","StatusMessage":""},"uuid":"6900e729-981d-4f54-b5cb-57b42a0ff7f0"}
{"@level":"info","@message":"requesting notarization info","@module":"notarize","@timestamp":"2021-07-09T04:49:58.452901Z","command_args":["xcrun","altool","--notarization-info","6900e729-981d-4f54-b5cb-57b42a0ff7f0","-u","***","-p","@env:AC_PASSWORD","--output-format","xml"],"command_path":"/usr/bin/xcrun","uuid":"6900e729-981d-4f54-b5cb-57b42a0ff7f0"}

....

{"@level":"info","@message":"notarization info","@module":"notarize","@timestamp":"2021-07-09T04:51:28.576004Z","info":{"RequestUUID":"6900e729-981d-4f54-b5cb-57b42a0ff7f0","Date":"2021-07-09T04:49:48Z","Hash":"738becd8f85a9d93dd07b7eff81ebbaa22a3d838590db327bd53d83581fcff0b","LogFileURL":"https://osxapps-ssl.itunes.apple.com/itunes-assets/Enigma125/v4/c2/cb/9e/c2cb9e74-1180-e771-681c-0269d14fb598/developer_log.json?accessKey=1626000688_1832227881924069867_Ntd8%2BNw54gpHakJyqB6Qjpvbw1DwwJJTbzBXczK2qqMmJIsjS5z2EB4YnL3CoHeod9r1AzbY7VENsvqTOiohUhIJ7RPx0KLGE59v0X5RF8fIBcUs2bcwNF%2BTAJSvAnOhoJNfCJTRqO4ANJ3%2FgSnneC%2FinKuboxAmir5RM%2Bn%2BSXI%3D","Status":"success","StatusMessage":"Package Approved"},"uuid":"6900e729-981d-4f54-b5cb-57b42a0ff7f0"}
{"@level":"info","@message":"downloading log file for notarization","@timestamp":"2021-07-09T04:51:28.576054Z","request_uuid":"6900e729-981d-4f54-b5cb-57b42a0ff7f0","url":"https://osxapps-ssl.itunes.apple.com/itunes-assets/Enigma125/v4/c2/cb/9e/c2cb9e74-1180-e771-681c-0269d14fb598/developer_log.json?accessKey=1626000688_1832227881924069867_Ntd8%2BNw54gpHakJyqB6Qjpvbw1DwwJJTbzBXczK2qqMmJIsjS5z2EB4YnL3CoHeod9r1AzbY7VENsvqTOiohUhIJ7RPx0KLGE59v0X5RF8fIBcUs2bcwNF%2BTAJSvAnOhoJNfCJTRqO4ANJ3%2FgSnneC%2FinKuboxAmir5RM%2Bn%2BSXI%3D"}
    [final.dmg] Status: success
    [final.dmg] File notarized!
    [final.dmg] Stapling...
{"@level":"info","@message":"executing stapler","@module":"staple","@timestamp":"2021-07-09T04:51:28.790943Z","command_args":["xcrun","stapler","staple","macbinaries/final.dmg"],"command_path":"/usr/bin/xcrun","file":"macbinaries/final.dmg"}
{"@level":"info","@message":"stapling complete","@module":"staple","@timestamp":"2021-07-09T04:51:29.856027Z","file":"macbinaries/final.dmg"}
    [final.dmg] File notarized and stapled!

Notarization complete! Notarized files:
  - macbinaries/final.zip (notarized)
  - macbinaries/final.dmg (notarized and stapled)

Error

image

What am I missing here?

FR: support for signing pkg files

Been playing around with gon for a few days now, and really enjoying it so far. Loving the async notarisation.

My one gripe is the lack of support for signing pkg files with an Installer ID, ie. using productsign instead of codesign. Is this an intended omission? Would love to see gon handle both cases properly, especially as the readme mentions pkg notarisation support, which led me to assume it could be signed too.

Happy to open a PR if you feel this would be a good idea but don't have any time to invest in it.

goreleaser signing using gon - "bundle format unrecognized, invalid, or unsuitable"

I am trying to sign my golang using goreleaser - and eventually distribute using Homebrew. But this will require signing with Apple Developer ID to be able to distribute to MacOs.

Also posted on Stackoverflow

Have you seen the following error using gon and fixed it?

yaml sample from here

## .goreleaser.yaml
# This is an example .goreleaser.yml file with some sane defaults.
# Make sure to check the documentation at http://goreleaser.com
before:
  hooks:
    # You may remove this if you don't use go modules.
    - go mod tidy
    # you may remove this if you don't need go generate
    - go generate ./...

builds:
- binary: foo
  id: foo
  goos:
  - linux
  goarch:
  - amd64
# notice that we need a separated build for the MacOS binary only:
- binary: foo
  id: appbrew-macos
  goos:
  - darwin
  goarch:
  - amd64
  hooks:
    post: gon gon.hcl

gon.hcl file

# The path follows a pattern
# ./dist/BUILD-ID_TARGET/BINARY-NAME

source = ["."]
bundle_id = "com.mydomain.mybrew"

apple_id {
    username = "<[email protected]>"
    password = "@keychain:developer_id_application"
}

sign {
  application_identity = "Developer ID Application: my name (452534542)"
}

I can verify that the password is retrieve using:

security find-generic-password -w -s 'developer_id_application' -a '<[email protected]>'

Error:

   • archives         
      • creating                  archive=dist/appbrew_0.1.19_Darwin_x86_64.tar.gz
      • creating                  archive=dist/appbrew_0.1.19_Darwin_arm64.tar.gz
      • creating                  archive=dist/appbrew_0.1.19_Linux_i386.tar.gz
      • creating                  archive=dist/appbrew_0.1.19_Linux_x86_64.tar.gz
      • creating                  archive=dist/appbrew_0.1.19_Linux_arm64.tar.gz
   • creating source archive
   • linux packages   
   • snapcraft packages
   • calculating checksums
      • checksumming              file=appbrew_0.1.19_Linux_arm64.tar.gz
      • checksumming              file=appbrew_0.1.19_Darwin_arm64.tar.gz
      • checksumming              file=appbrew_0.1.19_Linux_x86_64.tar.gz
      • checksumming              file=appbrew_0.1.19_Darwin_x86_64.tar.gz
      • checksumming              file=appbrew_0.1.19_Linux_i386.tar.gz
   • signing artifacts
      • signing                   cmd=[gon gon.hcl]
      • ==> ✏️  Signing files...
 cmd=gon
      • ❗️ Error signing files:

error signing:

.: bundle format unrecognized, invalid, or unsuitable

 cmd=gon
   ⨯ release failed after 3.49s error=sign: gon failed

Option to provide timestamp and other flags to codesign

This the error that I get

"
❗️ Error signing files:

error signing:

./servicego_macos_amd64: replacing existing signature
./servicego_macos_amd64: A timestamp was expected but was not found.

But I cannot find a way a supply the timestamp in config. As of now, I will delete the previously failed signed binary and create again.

Support ENV variables in source or as a flag

I'm not sure what's better in terms of UX, but I would find it really useful if gon accepted paths to binaries either as environment variables or as flags. This would allow for much cleaner integration with GoReleaser and probably other release software and CIs too.

Example

source = ["@env:BIN_PATH"]
bundle_id = "com.mitchellh.example.terraform"
apple_id {
  username = "[email protected]"
  password = "@env:AC_PASSWORD"
}
sign {
  application_identity = "Developer ID Application: Mitchell Hashimoto"
}
$ BIN_PATH=./path/to/binary gon .gon.hcl

Suggestion: allow passing extra flags to create-dmg

Hi! Thanks for this tool, it works great!

We just have a small issue: when it calls create-dmg, that tool tries to launch Finder to generate a .DS_Store file, but since I'm running it on a headless machine, it fails. The solution is to call it with the --skip-jenkins flag to avoid running Finder, and just bundle the file manually.

This is to say: it would be great if we could pass that flag to create-dmg from gon. I'd be happy to write a PR, but I'm wondering if you are OK with accepting that extra feature. My idea was to add an extra_args key in the dmg setting, like:

"dmg" :{
        "output_path":  "terraform.dmg",
        "volume_name":  "Terraform",
       "extra_args": "--skip-jenkins --icon-size 128"
    }

what do you think?

Notarization result wait process randomly fails with a plist type mismatch error about 5-10% of the time

I have a project that produces nightly builds of Emacs for macOS, and I'm pulling in gon as a Go package to handle the notarization and stapling.

However, every now and then it fails with a plist type mismatch error. It looks like Apple's notarization server sometimes returns some unexpected value.

From the most recent build:

2022-03-05T01:23:23Z [INFO]  notarize: notarizing: file=Emacs.2022-03-04.6ad223f.master.macOS-10-15.x86_64.dmg
2022-03-05T01:23:23Z [INFO]  notarize: submitting file for notarization...
2022-03-05T01:23:46Z [INFO]  notarize: submitted
2022-03-05T01:23:46Z [DEBUG] notarize: request: uuid=f300630d-9fa5-49c8-88cd-7d1a583dc2cd
2022-03-05T01:23:46Z [INFO]  notarize: waiting for result from Apple...
2022-03-05T01:23:58Z [INFO]  notarize: status update: status="in progress"
ERROR: failed to decode notarization submission output: plist: type mismatch: tried to decode plist type `dictionary' into value of type `string'

Despite this error, I still get a confirmation email from Apple telling me that notarization was successful. It normally takes about 10 minutes for Apple to notarize the build, and this error seems to happen randomly at any point throughout the waiting process.

I haven't dug any deeper yet, but figured I'd start reporting it here incase anyone else has seen this issue.

FR: Support for "deep" codesigning.

Using gon is a great experience - however, signing .app packages, is not.
As it stands now, each individual piece of code (binaries, libraries, frameworks) contained in the .app must be manually specified in the "source" config. This leads to wasted iteration cycles of having to manually add each failed item following a failed notarisation when developing on the package.

Now - I don't know if specifying each individual item is considered a feature or not - is this a "we need to be concise", or an oversight?

If the first - would be great to be able to fail-fast at codesign, instead of failing at notarisation (which can take a while)
If the second - support for signing entire .app files in one shot would be great. Whether that be by adding support for codesign's --deep flag (not sure if that satisfies this usecase), or some logic which is able to find and sign the prerequisites in the correct order.

Thanks for the tool though, it's a great help :)

question about the source parameter

So I'm trying to use gon to package a program I've writen on mac, and I'm a little confused about the source parameter in the config. Currently I have every file in the folder to be packaged in the source list, but is this correct? Or do I just need to include binaries, or even just the folder itself?
Thanks!
-Michael.

Will it work with Xcode 10.1?

My late 2011 laptop can't run a version of macos past High Sierra (10.13.6).
That limits my Xcode to 10.1 latest.

According to https://developer.apple.com/documentation/xcode/notarizing_macos_software_before_distribution:

Notarization requires Xcode 10 or later. Building a new app for notarization requires macOS 10.13.6 or later. Stapling an app requires macOS 10.12 or later.

Does gon work with XCode 10.1? The documentation states XCode 11 as a minimum but #21 states he got it to work (somehow) with XCode 10.3 on MacOS 10.14.6.

FR: Support for Appstore and Enterprise iOS code signing

Hi,

Using gon so far has been a great experience. Thank you so much for providing this tool. I was wondering if you're planning to offer mobile iOS code signing support with gon.
So specifically:

  • Is mobile support on the roadmap? How does it rank against other priorities?
  • If not, do you accept contributions? Do you have a contributor's guide somewhere?

Thanks once more!

Support reading Apple ID username/email from environment

Right now the properties within apple_id are being passed verbatim to altool, which has native support for reading Apple ID password from the environment (or keychain), but it would handy to also support providing the Apple ID username via an environment variable.

I'd like to commit my application's gon config to the repo that uses it, but would prefer to avoid publishing my Apple ID username/email.

If this seems reasonable, I can throw up a PR.

DMG option fails in GitHub Actions CI process

Hi,

for the following config

{
  "source" : ["target/EPUB-Checker.app"],
  "bundle_id" : "de.paginagmbh.epubchecker",
  "apple_id": {
    "username" : "",
    "password":  "",
    "provider": ""
  },
  "sign" :{
      "application_identity" : ""
  },
  "dmg" :{
    "output_path":  "target/pagina-EPUB-Checker.dmg",
    "volume_name":  "pagina EPUB-Checker"
  }
}

this GitHub Actions Workflow https://github.com/paginagmbh/EPUB-Checker/blob/development/.github/workflows/release.yml fails when gon is trying to create the DMG:

[INFO] ==> 📦  Creating dmg...
[INFO]     This will open Finder windows momentarily.
[INFO] {"@level":"info","@message":"executing create-dmg for dmg creation","@module":"dmg","@timestamp":"2020-03-21T20:13:15.326876Z","command_args":["create-dmg","--volname","pagina EPUB-Checker","--add-file","EPUB-Checker.app","./target/EPUB-Checker.app","0","0","./target/pagina-EPUB-Checker.dmg","/var/folders/24/8k48jl6d249_n_qfxwsl6xvm0000gn/T/gon526404065"],"command_path":"/var/folders/24/8k48jl6d249_n_qfxwsl6xvm0000gn/T/createdmg252459530/create-dmg","output_path":"./target/pagina-EPUB-Checker.dmg"}
[INFO] {"@level":"error","@message":"error creating dmg","@module":"dmg","@timestamp":"2020-03-21T20:15:27.890756Z","err":"exit status 64","output":"Creating disk image...\ncreated: /Users/runner/runners/2.165.2/work/EPUB-Checker/EPUB-Checker/target/rw.pagina-EPUB-Checker.dmg\nMounting disk image...\nUnmounting disk image...\nMount directory: /Volumes/pagina EPUB-Checker\nDevice name:     /dev/disk2\nCopying custom files...\n./target/EPUB-Checker.app\nRunning Applescript: /usr/bin/osascript \"/var/folders/24/8k48jl6d249_n_qfxwsl6xvm0000gn/T/createdmg.tmp.XXXXXXXXXX.c9uPdYuX\" \"pagina EPUB-Checker\"\n/var/folders/24/8k48jl6d249_n_qfxwsl6xvm0000gn/T/createdmg.tmp.XXXXXXXXXX.c9uPdYuX:394:406: execution error: Finder got an error: AppleEvent timed out. (-1712)\nFailed running AppleScript\n\"disk2\" ejected.\n"}
[INFO] ❗️ Error creating dmg:
[INFO] 
[INFO] error creating dmg:
[INFO] 
[INFO] Creating disk image...
[INFO] created: /Users/runner/runners/2.165.2/work/EPUB-Checker/EPUB-Checker/target/rw.pagina-EPUB-Checker.dmg
[INFO] Mounting disk image...
[INFO] Unmounting disk image...
[INFO] Mount directory: /Volumes/pagina EPUB-Checker
[INFO] Device name:     /dev/disk2
[INFO] Copying custom files...
[INFO] ./target/EPUB-Checker.app
[INFO] Running Applescript: /usr/bin/osascript "/var/folders/24/8k48jl6d249_n_qfxwsl6xvm0000gn/T/createdmg.tmp.XXXXXXXXXX.c9uPdYuX" "pagina EPUB-Checker"
[INFO] /var/folders/24/8k48jl6d249_n_qfxwsl6xvm0000gn/T/createdmg.tmp.XXXXXXXXXX.c9uPdYuX:394:406: execution error: Finder got an error: AppleEvent timed out. (-1712)
[INFO] Failed running AppleScript
[INFO] "disk2" ejected.
[INFO] 
[INFO] [ERROR] Command execution failed.

Do you have any idea why this might happen?

Thanks and best regards,
Tobias

Your Apple ID account is attached to other providers. You will need to specify which provider you intend to submit content to. Please contact us if you have questions or need help.

I had been using my personal Apple ID to sign a Golang-based CLI tool for work. But a couple of days ago, I got added to the company's Apple account, generated the cert and new bundle ID.

Today, I went to sign the binary with gon, and I got back the error message listed in the issue name. I have Xcode 11.5 installed and selected with xcode-select.

Your Apple ID account is attached to other providers. You will need to specify which provider you intend to submit content to. Please contact us if you have questions or need help.

Google has a large number of results, but this page suggests that it may require --itc_provider TEAM_ID to be passed one of the underlying tools inside Xcode.app.

Is this exposed anywhere in gon?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.