@@ -39,7 +39,24 @@ tool, [postject][]:
3939 $ cp $(command -v node) hello
4040 ```
4141
42- 3 . Inject the JavaScript file into the copied binary by running ` postject ` with
42+ 3 . Remove the signature of the binary:
43+
44+ * On macOS:
45+
46+ ``` console
47+ $ codesign --remove-signature hello
48+ ```
49+
50+ * On Windows (optional):
51+
52+ [ signtool] [ ] can be used from the installed [ Windows SDK] [ ] . If this step is
53+ skipped, ignore any signature-related warning from postject.
54+
55+ ``` console
56+ $ signtool remove /s hello
57+ ```
58+
59+ 4 . Inject the JavaScript file into the copied binary by running ` postject ` with
4360 the following options:
4461
4562 * ` hello ` - The name of the copy of the ` node ` executable created in step 2.
@@ -67,7 +84,24 @@ tool, [postject][]:
6784 --macho-segment-name NODE_JS
6885 ```
6986
70- 4. Run the binary:
87+ 5. Sign the binary:
88+
89+ * On macOS:
90+
91+ ```console
92+ $ codesign --sign - hello
93+ ```
94+
95+ * On Windows (optional):
96+
97+ A certificate needs to be present for this to work. However, the unsigned
98+ binary would still be runnable.
99+
100+ ``` console
101+ $ signtool sign /fd SHA256 hello
102+ ```
103+
104+ 6 . Run the binary:
71105 ``` console
72106 $ ./hello world
73107 Hello, world!
@@ -138,9 +172,11 @@ to help us document them.
138172[ ELF ] : https://en.wikipedia.org/wiki/Executable_and_Linkable_Format
139173[ Mach-O ] : https://en.wikipedia.org/wiki/Mach-O
140174[ PE ] : https://en.wikipedia.org/wiki/Portable_Executable
175+ [ Windows SDK ] : https://developer.microsoft.com/en-us/windows/downloads/windows-sdk/
141176[ `process.execPath` ] : process.md#processexecpath
142177[ `require()` ] : modules.md#requireid
143178[ `require.main` ] : modules.md#accessing-the-main-module
144179[ fuse ] : https://www.electronjs.org/docs/latest/tutorial/fuses
145180[ postject ] : https://github.com/nodejs/postject
181+ [ signtool ] : https://learn.microsoft.com/en-us/windows/win32/seccrypto/signtool
146182[ single executable applications ] : https://github.com/nodejs/single-executable
0 commit comments