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

Unable to sign x.app file #33

Open
junmaqiang opened this issue Oct 29, 2023 · 15 comments
Open

Unable to sign x.app file #33

junmaqiang opened this issue Oct 29, 2023 · 15 comments

Comments

@junmaqiang
Copy link

junmaqiang commented Oct 29, 2023

①The compiled file under the Apple system is x.app. When signing, it prompts that the directory cannot be signed.

②## Should we also add zip and rar decompression processes?

@andydotxyz
Copy link

Please add more information. This library does work, and is tested regularly, with macOS.

@Bluebugs
Copy link

I am guessing from the message that he is trying to sign a directory and not the application binary itself.

@junmaqiang
Copy link
Author

@Bluebugs yes you are very smart

I don’t know how to use the selfupdate function in an .app developed with fyne

@mottle-ai
Copy link

I have the same question.

I'm uploading a mac update to my cloud bucket - and executable that was previously code signed and part of a bundle notarized by Apple: AppName-darwin-amd64

This is effectively this file: AppName.app/Contents/MacOS/AppName, just renamed

Selfupdate detects this new version from the cloud, and downloads it, but nothing happens.

When I inspect AppName.app/Contents/MacOS/AppName, it hasn't been updated. (Updated timestamp still the same.)

Surely some kind of security issue going on, probably with code signatures etc relating to the old master .app.

Is this supposed to work, or is this only for apps that aren't doin the whole code signature / notarization rigmarole ....?

Note, I've given the app com.apple.security.automation.apple-events entitlements, as I saw an error relating to this that looked related. Didn't solve the problem.

I now see the following error in the logs:

RBSStateCapture remove item called for untracked item <numbers removed> (target:[app<application.com.app.AppName.<more numbers removed>(501)>:23687])

@Bluebugs
Copy link

@mottle-ai It will be useful if you could set the 3 functions provided for logging in the package: LogDebug, LogInfo and LogError ( https://pkg.go.dev/github.com/fynelabs/selfupdate?utm_source=godoc#LogDebug ) and see what the logs are saying.

@mottle-ai
Copy link

Thanks for the fast reply!

This is the error I get:

2024/01/26 16:36:28 Upgrade error: open /Applications/AppName.app/Contents/MacOS/.AppName.new: permission denied

I assume this has something to do with the hardened runtime?
https://developer.apple.com/documentation/security/updating_mac_software

@Bluebugs
Copy link

We actually already do a rename as described in the documentation. Is it possible that the application was installed by a different user and that you do not have the right to alter it?

@ruianderson
Copy link

@Bluebugs any way you think we could patch the process to replace the .app instead of only the executable?

I saw electron updater and it uses Squirrel.Mac and when the app is installed it will download the new .app in a zip file, do the checks and finally replace the package within ~/Applications folder

@Bluebugs
Copy link

@Bluebugs any way you think we could patch the process to replace the .app instead of only the executable?

I saw electron updater and it uses Squirrel.Mac and when the app is installed it will download the new .app in a zip file, do the checks and finally replace the package within ~/Applications folder

This is a good question. I don't have currently a good answer. My main concern is how do you get this to fit with something like tuf. Do you need to with zip and ship the entire package, or is it best to have per file update mechanism or should we bring in binary diff update.

I think we should move this part of the discussion to it own issue to figure out what we want to do for application package delivery, on what platform and for what purpose.

@mottle-ai
Copy link

Just a quick update: I was able to change the way I install the pkg so that I can install as the user, not as root (using a postinstall script). That solves the permission issue, and the update is applied. However, now the application then won't restart because of course the code signature checks fail.
It would be amazing if a single .zip containing the new .app could be downloaded, and the entire .app replaced...

@Bluebugs
Copy link

Bluebugs commented Feb 1, 2024

So apple signature is not applied on the binary, but only in the .app/zip file?

@mottle-ai
Copy link

mottle-ai commented Feb 1, 2024

Screenshot 2024-02-02 at 10 30 57 am

Yes, MacOS apps is basically a little directory structure that looks like a single executable file.
You can see here that, after the update, the MacOS directory has been updated -- this is where the binary is kept -- but the _CodeSignature directory has not been updated with the new signature.
When I run pkgutil --check-signature AppName.app the signature is invalid

@Bluebugs
Copy link

Bluebugs commented Feb 2, 2024

Following https://servicemax.com.au/tips/signing-and-notarising-a-mac-binary-written-in-go/ could you try signing just the binary?

@mottle-ai
Copy link

Following https://servicemax.com.au/tips/signing-and-notarising-a-mac-binary-written-in-go/ could you try signing just the binary?

Yes, this is what I already do. My build file looks very similar to this ...

I suspect though, if you patch in a binary to an .app that's been signed previously, you break the signature on the .app? (tbh, I'm not sure.)

@Bluebugs
Copy link

Bluebugs commented Feb 3, 2024

That link describe two signature method. One for the bundle (.app) and one for the binary itself. I am thinking, but haven't tried, that once a binary is signed (but not the bundle, as it is optional), it should be OK to use it for update. It means that existing installation can't be updated if the bundle is signed, but should if just the binary is and the binary is also signed.

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

No branches or pull requests

5 participants