Skip to content

Ensure our release binaries work on Apple Silicon #2426

Description

@mislav

It looks like macOS arm64 architecture requires all Go binaries to be signed: golang/go#42684

We currently produce macOS binaries from Linux, but if we switch our release automation to compiling them from macOS, this might be enough to alleviate this. I'm not yet sure whether that would require the Actions runner to also be arm64.

Activity

  1. wiesson commented on Nov 19, 2020

    @wiesson

    If there is anything to test, I'm happy to help :)

  2. AndrewSB commented on Dec 5, 2020

    @AndrewSB

    this isn't directly useful for your signing question, but since this is the search result for "Apple Silicon" in this repo, I'm sharing my experience:

    1. I couldn't install through brew since go is currently broken on brew
    2. I downloaded the latest release (gh_1.3.1_macOS_amd64.tar.gz at the time of writing) untarred, and tried to run. I was hit with an untrusted binary error from Apple.
    3. I opened gh_1.3.1_macOS_amd64/bin/gh with a right click through Finder and was given the option to run anyway. That succeeded.
    4. I sudo mv gh_1.3.1_macOS_amd64/bin/gh /usr/local/bin (which I've added to my $PATH), and it's working great!

    as an aside: I have a valid go binary that I compiled myself in my $PATH. I'm assuming that doesn't affect gh, since I downloaded a binary that shouldn't look for the go executable, but if you're having trouble replicating my instructions you might need to get a working go on your machine first

  3. richiksc commented on Dec 10, 2020

    @richiksc
    1. I downloaded the latest release (gh_1.3.1_macOS_amd64.tar.gz at the time of writing) untarred, and tried to run. I was hit with an untrusted binary error from Apple.
    2. I opened gh_1.3.1_macOS_amd64/bin/gh with a right click through Finder and was given the option to run anyway. That succeeded.
    3. I sudo mv gh_1.3.1_macOS_amd64/bin/gh /usr/local/bin (which I've added to my $PATH), and it's working great!

    @AndrewSB This was also my experience installing gh on an M1 MacBook. I didn't attempt to install through brew, but I downloaded the tar, manually cleared it through Finder (could also be done with the xattr com.apple.quarantine command I believe), and then moved it to /usr/local/bin. I don't have go installed, so it doesn't look like you need a go binary installed for it to work.

    @mislav I don't know about Go, but I built a Rust binary on a standard macosx11.0 x86_64 GitHub Actions runner using the aarch64-apple-darwin toolchain in Rust v1.49 beta, and the binary it produced was signed.

    Here's the output from running codesign --verify --verbose [my_binary] on that after freshly downloading it:

    % codesign --verify --verbose badlogvis-aarch64-apple-darwin 
    badlogvis-aarch64-apple-darwin: valid on disk
    badlogvis-aarch64-apple-darwin: satisfies its Designated Requirement
    

    Edit: for comparison, here's the output of codesign --verify for freshly downloaded and untarred gh:

    % codesign --verify --verbose gh
    gh: code object is not signed at all
    In architecture: x86_64
    
  4. flying-sausages commented on Dec 23, 2020

    @flying-sausages

    FWIW I got the thing to compile on an M1 from source when using this brew PR Homebrew/homebrew-core#67154

    cd /opt/homebrew/Library/Taps/homebrew/homebrew-core
    arch -x86_64 gh pr checkout 67154
    HOMEBREW_NO_AUTO_UPDATE=1 brew install --HEAD --build-from-source go --verbose
    HOMEBREW_NO_AUTO_UPDATE=1 brew install --build-from-source gh --verbose
    echo "vois la"

    image

    gh.tar.gz

  5. flying-sausages commented on Dec 26, 2020

    @flying-sausages

    go @ 1.16 pre-relase go merged into brew master so this shoud be possible now by just running brew install gh -s without any of the stuff above. Not sure a bottle's been built yet.

  6. richiksc commented on Dec 26, 2020

    @richiksc

    go @ 1.16 pre-relase go merged into brew master so this shoud be possible now by just running brew install gh -s without any of the stuff above. Not sure a bottle's been built yet.

    @flying-sausages A bottle has been built! I installed the native version this morning with brew install gh and it works like a charm. No more long delays for random actions especially opening things in the web browser with gh pr/issue view --web compared to the Rosetta 2 binary.

  7. ervaneet82 commented on Feb 5, 2021

    @ervaneet82

    gh is installed in Mac silicon laptop but when I run the gh repo clone xxx/repo , it’s not working

  8. mislav commented on Feb 5, 2021

    @mislav
    ContributorAuthor

    @ervaneet82 I'm sorry, but you will have to report your issue more specific than that. How did you install gh? Which error did you get?

    Our release binaries are not compatible with M1 yet, but you can use Homebrew to run brew install gh. Please try that first.

  9. richiksc commented on Feb 5, 2021

    @richiksc

    you can use Homebrew to run brew install gh -s

    FYI, the -s flag is no longer needed, since Homebrew has pre-built bottles available for gh on arm64.

  10. ervaneet82 commented on Feb 5, 2021

    @ervaneet82

    Hi ,

    Simple install but first you need to run "xcode-select --install" after that I ran the following commands.

    • brew install gh

    • which gh

    • /opt/homebrew/bin/gh

    gh repo clone ervaneet82/terraform12
    signal: killed ---> This is error coming getting

    MacBook Pro (13-inch, M1, 2020)

  11. mvllow commented on Feb 5, 2021

    @mvllow

    gh repo clone ervaneet82/terraform12 signal: killed ---> This is error coming getting

    @ervaneet82 You most likely don't have the arm64 version

    $ file $(which gh)
       → /opt/homebrew/bin/gh: Mach-O 64-bit executable arm64
  12. ervaneet82 commented on Feb 6, 2021

    @ervaneet82

    I have arm64.

    Vaneets-MacBook-Pro ~ % file $(which gh)
    /opt/homebrew/bin/gh: Mach-O 64-bit executable arm64

  13. richiksc commented on Feb 6, 2021

    @richiksc

    I have arm64.

    Vaneets-MacBook-Pro ~ % file $(which gh)
    /opt/homebrew/bin/gh: Mach-O 64-bit executable arm64

    Do you have git installed?

  14. 9 remaining items

  15. added
    coreThis issue is not accepting PRs from outside contributors
    on Feb 21, 2022
  16. itsMaxC commented on Mar 24, 2022

    @itsMaxC

    @mislav any updates on this?

  17. llvm-beanz commented on Apr 15, 2022

    @llvm-beanz

    Assuming “most” macOS users use homebrew is a bad assumption. Homebrew and macPorts both have huge security holes that make them unsuitable for many environments. Also, not codesigning binaries, which is not an Apple Silicon specific issue, requires disabling security features of the OS.

    You should either code sign your releases, or stop shipping them for macOS.

  18. mislav commented on May 4, 2022

    @mislav
    ContributorAuthor

    You should either code sign your releases, or stop shipping them for macOS.

    We are already planning to code-sign binaries attached to gh releases, which this ticket is about. I'm not sure which new information you are bringing to this thread, but it feels like your intent is merely to rush us into doing so? Please note that Apple has started enforcing binary-signing restrictions after we started publishing gh, so it's not like we planned to deliberately go against Apple's guidelines.

    We force no one to use our precompiled binaries, nor to use Homebrew or MacPorts. Anyone can compile gh by themselves, which you should absolutely do if security is paramount on your own machines. Over time, we will work incrementally to improve our precompiled binaries to the best of our team's abilities.

  19. llvm-beanz commented on May 4, 2022

    @llvm-beanz

    We are already planning to code-sign binaries attached to gh releases, which this ticket is about. I'm not sure which new information you are bringing to this thread, but it feels like your intent is merely to rush us into doing so? Please note that Apple has started enforcing binary-signing restrictions after we started publishing gh, so it's not like we planned to deliberately go against Apple's guidelines.

    This issue has been around for a long time and is a security issue for your users. It should be treated with appropriate priority.

    Apple's guidelines have advised code signing since macOS 10.8 with the introduction of GateKeeper. Ever since 10.8 you've had to set a setting to disable codesign enforcement on macOS, which has weakened the security of the system.

    Since the release of Apple Silicon macs code signatures became a hard requirement, but this is not new. Code signing has been part of Apple's guidelines for macOS development for almost a decade, far longer than gh has existed.

  20. moved this from 🆕 New to 📋 Backlog in @n8felton's backlogon Nov 4, 2022
  21. moved this from 📋 Backlog to 6️⃣4️⃣ Apple Silicon (arm64) support in @n8felton's backlogon Nov 4, 2022
  22. added 2 commits that reference this issue on Feb 2, 2023
    62fba0f
    b03d137
  23. akirchhoff-modular commented on Feb 5, 2023

    @akirchhoff-modular

    Note that the original Go issue linked from here (golang/go#42684) is now resolved. Go ad-hoc signs all macOS binaries by default, even when cross-building. This is sufficient -- I've tested this, and just adding arm64 to the architectures in the goreleaser configuration is sufficient to get binaries that run on Apple Silicon Macs, even when cross-building from Linux.

  24. moved this from 🦾6️⃣4️⃣ Si (arm64) support to ✅ Done in @n8felton's backlogon Feb 17, 2023
  25. mislav commented on Feb 17, 2023

    @mislav
    ContributorAuthor

    Hi all, thanks for contributing to this discussion and for your patience. We are moving forward with signing & notarizing our macOS builds, but seeing as we still have a few items to check off before all that's done, we will be shipping this in two steps:

    1. We will add an arm64 build to our Releases starting from the next release. Initially, this build might not be signed with a valid Developer identity nor notarized (that will be covered by step 2), but even without a valid signature, this will help scripts that programmatically download builds from our Releases section. This marks this thread as closed.

    2. We will add developer signature & notarization to our amd64 and arm64 builds for macOS. This will enable the extracted gh binaries to run on macOS after using a web browser to download our Release tarballs, as well as hopefully improve users' trust in our binaries. We are tracking this in macOS binaries not signed with a verified identity #6970

    Step 1 is easy and immediately shippable; step 2 will be delayed by us having to first procure an Apple Developer identity and modify our release automation process to include a notarization step.

    Why did this take so long?

    Since GitHub CLI is a tool primarily aimed at developers, signing & notarizing wasn't strictly necessary from our point of view, and it was easier for us to set up release automation without it. Developers tend to use package managers to obtain command-line tools, and since Homebrew is our primary distribution mechanism for macOS users, anyone on Intel or Apple Silicon architectures was able to brew install gh and have GitHub CLI working without any other restrictions.

    What Homebrew does is either compiles gh from source, which results in an ad-hoc signed binary courtesy of the Go toolchain, or downloads a pre-built "bottle" of gh for your architecture and applies an ad-hoc signature to it after downloading.

    For those who do not wish to use Homebrew, after we generate arm64 builds in the next release, any script or package manager will be able to wget https://github.com/cli/cli/releases/download/v{VERSION}/gh_{VERSION}_macOS_arm64.tar.gz, extract it, and have gh working on their machine. To my knowledge and in my testing, using a command-line tool such as wget or curl to obtain a package will not trigger Gatekeeper's restrictions on running unpacked software.

    Gatekeeper, the runtime security mechanism built into macOS, seems to only kick in when a GitHub CLI package was downloaded via a web browser: i.e. by navigating to our Releases section and downloading a package from there. According to xattr <file>, this sets the com.apple.quarantine attribute, which is copied to the gh binary after extraction, which serves as a signal to the system to exercise extra precaution with this executable at runtime.

    A valid signature and notarization for our binary will help avoid this notice by Gatekeeper, but until then, please either use Homebrew or use a command-line tool to download and extract our release packages for macOS.

    Addendum for posterity

    How to verify a signature of an executable, including ad-hoc signatures:

    $ codesign --verify -vvvv gh_2.23.0_macOS_arm64/bin/gh
    gh_2.23.0_macOS_arm64/bin/gh: valid on disk
    gh_2.23.0_macOS_arm64/bin/gh: satisfies its Designated Requirement
    

    How to verify whether a quarantined executable will be allowed to run:

    $ spctl --asses --verbose gh_2.23.0_macOS_arm64/bin/gh
    gh_2.23.0_macOS_arm64/bin/gh: rejected
    
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    coreThis issue is not accepting PRs from outside contributorspackaging

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions