main executable failed strict validation when signing binary on macOS
See original GitHub issueI’m getting an error when code-signing a binary produced by pkg on macOS:
main executable failed strict validation
I couldn’t find much information about this on the web, but some causes can be (from https://developer.apple.com/library/content/technotes/tn2206/_index.html#//apple_ref/doc/uid/DTS40007919-CH1-TNTAG309):
- Your Mach-O executable does not conform to modern Mach-O layout rules
- You may be using a third party development product that hasn’t been brought up to date, or post-processed your file in unsupported ways
Do you know thay may be causing this? codesign succeeds with other binaries.
Steps to reproduce:
git clone https://github.com/resin-io/etcher
cd etcher
make cli-develop
pkg --output etcher -t node6-macos-x64 lib/cli/etcher.js
codesign --sign "<identity>" -fv etcher
Issue Analytics
- State:
- Created 6 years ago
- Reactions:19
- Comments:63 (3 by maintainers)
Top Results From Across the Web
Understanding OS X and iOS Code Signing to Hide Data
This is a talk about all three in regards to Apple OS X and iOS code signing. ... /Applications/Firefox.app: main executable failed strict...
Read more >Technical Note TN2206: macOS Code Signing In Depth
codesign says my main executable failed strict validation. I wrote some data to the Mach-O file before signing. Is that allowed?
Read more >macOS Catalina Notarization: "failed strict validation" error ...
I have packaged a Node.js script into an executable using pkg. With the macOS catalina release, all software should be notarized by Apple....
Read more >MacOS build_apps and code signing, fails with main ...
... I wanted to make sure that I can build and distribute binaries. ... code signing, fails with main executable failed strict validation...
Read more >Cannot build a macOS App with a provisioning profile
This is what Apple support says: codesign says my main executable failed strict validation. · Select “None” for the OS X build's “Provisioning...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
FWIW I’ve tried all of them and none of them generate executables that can be signed. I’m skipping the middle man now and just building Node from source (which is what all of these
npmpackages do), usingwebpackto compile my app to a single file and dropping it inlib/_third_party_main.js(there are a few C++/JS changes required). Anyway, now I can create an executable that can be properly signed and can add the executable to a.pkginstaller and notarize.Here’s my fork of Node that I’m using.
Like I said, I copy the file generated by webpack to
lib/_third_party_main.jsand run the following from the node source root:Which produces
out/Release/node. That file is then moved tomy-executable-namefor signing. You will also need anentitlements.xmlfile so you can use the hardened runtime option, here’s mine:Here is my
codesigncommand:Nearly two years on from when this issue was first logged, I’m wondering can someone tell us please if there is any progress on this code signing issue with PKG? (I’m getting the same “main executable failed strict validation” issue.)
It’s not an option for us to distribute and install pkg components on client machines without having them code signed, which effectively renders PKG useless for our needs, as far as I can tell.
Is there a valid workaround for this issue? The suggestion by @gimdongwoo to change the extension allows you to code sign an app containing PKG components, but because they’re renamed, they can’t be executed as far as I can tell, as they’re no longer regarded as Unix executables but as documents (which presumably is why they’re now passing validation as the validation rules are different for documents vs executables?).
Is there a way to rename a pkg package and still execute it? In our case, our pkg components are installed inside the application package contents (i.e. show package contents, then within
contents\services\<pkg packages here>) so we can’t rename those back to remove the extension after installing. Note that trying to execute them after renaming to include an extension pops up a mac dialogue saying there’s nothing associated with that extension, as the system thinks they’re ‘documents’ rather than an executables.So, can you at least tell us please if a viable fix is going to be released soon? Or is this an issue that can’t or won’t be fixed, in which case our only option is to look for an alternative packaging system for our node components?