-
Notifications
You must be signed in to change notification settings - Fork 1k
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
Add Mono's signcode for non-Windows builds #505
Conversation
@paulcbetts I'm not much of a C# guy, but does this look good? |
@kevinmartin I'm not super excited to hoist the "You need different params" onto users, are we 100% sure that we can't get signtool.exe to work? |
Like I said above, @paulcbetts, I'm not a C# guy. I tried to look for a solution though and nothing. They all recommend either using |
@kevinmartin No worries, thanks for the PR - I'll look into it and bite the bullet if there's no other option |
@paulcbetts, Excellent. I don't mean to be pushy, but when do you expect to be able to merge and release this? |
src/Update/Program.cs
Outdated
#if MONO | ||
// Use Mono's signcode tool | ||
var exe = "signcode"; | ||
#endif; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Xamarin Studio choked on that for me, you don't need to use ;
after a directive.
Also, #else
exists, it's better than two if VAL
/ if !VAL
blocks 👍
The only problem with that branch is that signcode will try to read the pvk's password from standard input. Not sure yet how to deal with that. |
The workaround to that is to import the private key with mono's certmgr -importKey -c -v -p "PFX_PASSWORD" My PFX_PATH Explanation:
Once that's done, you can (should!) delete the pfx, and omit the (Sorry if it I'm hijacking this PR, hopefully it'll help people who google this info) |
Annoyingly, Mono's signcode creates a Hence, I'd rather use osslsigncode, personally. Reopening #521 since it would support both usecases, will submit PR later today. |
@fasterthanlime Can't we just delete the backup file after-the-fact? |
@paulcbetts yes, if you add a codepath for it in cf. #522 for longer rants |
in case it's non-obvious: in the installer building process, If |
This is a ton of good research, huge thanks to both of you. So my plan is:
|
Sounds like a plan. I'm in no great hurry for this to land as I managed to get the whole chain running in our forks of Squirrel.WIndows + grunt-electron-installer. @paulcbetts would you consider - at some point - supporting osslsigntool even if you get signtool.exe working ? it would still be a good alternative (only deps are openssl and curl, works damn fast). |
Over a year later, I'm assuming this PR is no longer valid? This issue still exists with the latest Wine, Mono, and OSX. Related: electron/windows-installer#27 |
@dustinblackman personally, I gave up and am now using native Windows workers to package and sign installers. |
@fasterthanlime Built a dirty workaround instead as I don't feel like booting up VMs just for signing. For all you Googlers ending up here looking for a solution, this may do it. https://github.com/dustinblackman/mono-signtool |
@dustinblackman marketing tip: don't call it a dirty hack, call it a "drop-in replacement" 🙂 |
for those that are running into issues with the "drop-in replacement" 😉 mentioned in #505 (comment) (for me it just hangs because it probably fails in calling osslsigncode and it doesn't handle that properly due to the for-loop-sleep pattern), I'm actually having success with the following process:
|
@andreineculau I ran into the same issue with "mono-signtool" freezing up during the call to osslsigncode. When I attempt your workaround, Squirrel introduces an unsigned exe at some point when creating the installer. Post-installation, the install directory contains: I'm not sure at what point the unsigned exe is being created, or whether this is configurable somewhere. For now, the only way I can create a working installer is to build on Windows and let Squirrel do the signing. |
@andreineculau @collinbachi I'm running into the same issue @collinbachi mentioned when I attempt to manually sign the contents using signcode npm module, run electron-winstaller and then also sign the installer. When I ultimately install the application using the installer, I notice that the root directory application exe is not signed nor is squirrel.exe, despite both being signed prior to creating the installer. Did anyone find a workaround? Even though I can now manually sign the contents and the installer, after installation somehow several EXEs are left unsigned. Seems like something that happens during the electron-winstaller process. |
EDIT: I see that I missed providing I don't know what to say, but below you have the exact Makefile excerpt that we run regularly on travis ci (ubuntu xenial) to build signed win32 binaries cd "$(DIST_TARGET_DIR)" && \
$(FIND_Q_NOSYM) . -type f \( -name "*.exe" -o -name "*.dll" -o -name "*.node" \) -print | while read f; do \
$(ECHO_DO) "Signing $$f..."; \
$(MV) "$$f" "$$f.unsigned"; \
$(OSSLSIGNCODE) \
-h sha1 \
-in "$$f.unsigned" \
-out "$$f.sha1-signed" \
-t http://timestamp.verisign.com/scripts/timstamp.dll \
-pkcs12 $(GIT_ROOT)/$(WIN32_P12) \
-pass $(WIN32_P12_PASS); \
$(OSSLSIGNCODE) \
-nest \
-h sha256 \
-in "$$f.sha1-signed" \
-out "$$f" \
-t http://timestamp.verisign.com/scripts/timstamp.dll \
-pkcs12 $(GIT_ROOT)/$(WIN32_P12) \
-pass $(WIN32_P12_PASS); \
$(RM) "$$f.unsigned"; \
$(RM) "$$f.sha1-signed"; \
$(ECHO_DONE); \
done
$(ELECTRON_INSTALLER_WINDOWS) \
--src "$(DIST_TARGET_DIR)" \
--dest dist/installers/ \
--platform $(DIST_TARGET_OS) \
--arch $(DIST_TARGET_ARCH)
cd dist/installers && \
$(ECHO) "$(PKG_NAME_EIW)-$(PKG_VSN)-setup.exe" | while read f; do \
$(ECHO_DO) "Signing $$f..."; \
$(MV) "$$f" "$$f.unsigned"; \
$(OSSLSIGNCODE) \
-h sha1 \
-in "$$f.unsigned" \
-out "$$f.sha1-signed" \
-t http://timestamp.verisign.com/scripts/timstamp.dll \
-pkcs12 $(GIT_ROOT)/$(WIN32_P12) \
-pass $(WIN32_P12_PASS); \
$(OSSLSIGNCODE) \
-nest \
-h sha256 \
-in "$$f.sha1-signed" \
-out "$$f" \
-t http://timestamp.verisign.com/scripts/timstamp.dll \
-pkcs12 $(GIT_ROOT)/$(WIN32_P12) \
-pass $(WIN32_P12_PASS); \
$(RM) "$$f.unsigned"; \
$(RM) "$$f.sha1-signed"; \
$(ECHO_DONE); \
done |
Since
signtool.exe
is broken with Mono, use Mono's built-insigncode
tool.This update
signcode
is available on the$PATH
and that the developers signing the the release needs to put different options in--signWithParams
to accommodate for the change.Sample signing:
More details can also be found at MDN: https://developer.mozilla.org/en-US/docs/Signing_an_executable_with_Authenticode
Fixes: #496