question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

nexe converted node.js file no longer produces valid Mach-O (fails codesign)

See original GitHub issue

This is a

  • Bug Report
  • Feature Request
  • Other

Hi,

I used nexe to transform a Node.js file to an executable used by a macOS application.

I recently updated to 2.0.0-rc.29 (from a version a ~year ago) and it no longer works.

First, I had an issue where Xcode codesign would fail:

codesign says my main executable failed strict validation.
- 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.

That got fixed by the following issues / hack:

https://github.com/nexe/nexe/issues/446 https://github.com/nexe/nexe/issues/470

But then I had another error:

caught error in https
ReferenceError: net is not defined
    at Server.server.on (_third_party_main.js:212:14)
    at Server.emit (events.js:182:13)
    at onParserExecuteCommon (_http_server.js:535:14)
    at onParserExecute (_http_server.js:482:3)

These are the “imports” I used:

const http = require('http');
const httpProxy = require('http-proxy');
const fs = require('fs');
const parseDomain = require('parse-domain');

I guess this is a result of “resources” not working:

Nexe relies on mangling the base binary which inherently breaks signing. Using the patch shown in that comment should allow you to embed your application fully. However, resources will not work.

Is there any way around this? Maybe I should use something else? Or maybe there is planned support for it?

Thank you, and I appreciate the library. It helped to quickly transform code written in Node to be used in macOS.


  • Platform(OS/Version): macOS 10.13.15
  • Host Node Version: v10.3.0
  • Target Node Version: v10.3.0
  • Nexe version: 2.0.0-rc.29
  • Python Version: 2.7.10

Issue Analytics

  • State:open
  • Created 5 years ago
  • Reactions:3
  • Comments:9

github_iconTop GitHub Comments

2reactions
btsimonhcommented, Oct 8, 2019

OSX signing is evil. Basically, you can’t sign something which has had stuff appended to it (like a new nexe app has). I recently spend 2 weeks making my (heavily modified old NEXE app using lockwrap for a filesystem) work for OSX. The solution I came up with was as follows: Because an OSX ‘APP’ is normally delivered as a folder structure, you can include data files in your deployment. So, quite simply, I modified my ‘internal’ nexe javascript (the stuff which is compiled in) to look for the packaged filesystem in a known datafile, and if that failed, look on the end of the exe (e.g. for win32 or linux). This allows you to sign the (now valid) OSX plain executable, and the data file get’s signed separately, then it all works, and even passed their new ‘let apple virus scan it’ system… 😃.

Now trying to upgrade from node 6.9.11 to node 12.10.0 using latest nexe… more heavy nexe modifications required 😃 (but once done the OSX should still be fine).

p.s. if someone really wants a challenge, check out my fork of isign - OSX signing without OSX - I gave up at the last hurdle, but maybe someone with better python/openssl experience can take it on…

0reactions
btsimonhcommented, Jan 5, 2021

The signing is: sudo codesign -vvvv --force --options runtime --timestamp --entitlements ./osx-entitlements.plist -fs “my stuff” ./dmg.12.13.0/myapp.app

and test: echo test signing codesign -dv --verbose=4 ./dmg.12.13.0/myapp.app echo test signing with spctl spctl --assess --verbose ./dmg.12.13.0/myapp.app

what fun OSX is!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Technical Note TN2206: macOS Code Signing In Depth
This document is not meant to be applied to code signing on iOS, however. ... codesign says my main executable failed strict validation....
Read more >
ExpressJs is return error `ERR_MODULE_NOT_FOUND` if I ...
If someone is still searching, I got this error using node version 15, I was importing the files without the .js file extension, ......
Read more >
15 Common Error Codes in Node.js and How to Fix Them
Therefore, we've compiled this list of 15 common Node.js errors along with one or more strategies to follow to fix each one. While...
Read more >
Errors | Node.js v19.3.0 Documentation
stack or Error.captureStackTrace(obj) ). The default value is 10 but may be set to any valid JavaScript number. Changes will affect any stack ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found