windows-installer icon indicating copy to clipboard operation
windows-installer copied to clipboard

Is codesigning supposed to work from non-windows?

Open jkudish opened this issue 8 years ago • 30 comments

When I try to build the app from a non-windows machine (Ubuntu 15.10 in this case), I get the following error:

Error: Failed with exit code: 255
Output:
System.AggregateException: One or more errors occurred. ---> System.Exception: Failed to sign, command invoked was: '[path censored]/node_modules/electron-winstaller/vendor/signtool.exe sign /a /f "/[path censored]/build/codesigningcertificate.pfx" /p "[password censored]" [path truncated]/.local/share/SquirrelTemp/tempa/lib/net45/[filename censored].exe'

There's also a long stacktrace not included for the sake of brevity.

jkudish avatar Mar 06 '16 02:03 jkudish

It doesn't at the moment, wine doesn't correctly support code signing

anaisbetts avatar Mar 06 '16 03:03 anaisbetts

Solution: https://developer.mozilla.org/en-US/docs/Mozilla/Developer_guide/Build_Instructions/Signing_an_executable_with_Authenticode

develar avatar Mar 11 '16 08:03 develar

Supposedly, according to the MDN article, wine supports code signing. Is the article out of date?

feross avatar Apr 14 '16 21:04 feross

I'm working on a fix for this currently to use https://sourceforge.net/projects/osslsigncode/ to sign windows assets from mac.

My plan is to add support for it here for installers and on electron-packager for .exe.

kevinsawicki avatar Apr 14 '16 21:04 kevinsawicki

I tried to use signcode (instead of osslsigncode) originally from that mdn article but it does not appear to support sha256 signatures which Windows 10 requires I believe.

kevinsawicki avatar Apr 14 '16 21:04 kevinsawicki

@kevinsawicki Do you mean the example just shows sha1, or the signcode tool actaully doesn't support sha256?

feross avatar Apr 14 '16 21:04 feross

Also, thanks for working on this!

feross avatar Apr 14 '16 21:04 feross

Do you mean the example just shows sha1, or the signcode tool actaully doesn't support sha256?

signcode only supports sha1 or md5 I believe.

Usage: signcode [options] filename

    -spc spc    Software Publisher Certificate file
    -v pvk      Private Key file
    -a md5 | sha1   Hash Algorithm (default: MD5)
    -$ indivisual | commercial  Signature type

https://github.com/mono/mono/blob/5e80f625b93706328c9a22b1cbb73300f2ea2186/mcs/tools/security/signcode.cs#L38

kevinsawicki avatar Apr 14 '16 21:04 kevinsawicki

Atom switched to dual signing via native signtool awhile ago with sha1 and sha256 signatures and I couldn't get that working with signcode.

kevinsawicki avatar Apr 14 '16 21:04 kevinsawicki

electron-builder discussion here: https://github.com/electron-userland/electron-builder/issues/314

feross avatar Apr 16 '16 02:04 feross

@kevinsawicki just published kevinsawicki/signcode which I think should be used in windows-installer when building from OS X.

feross avatar Apr 19 '16 00:04 feross

I'm currently trying to do the signing myself using osslsigncode or signcode to sign on my mac for the time being. But I'm curious as to what all files I have to sign? Do I sign all the Squirrel .exe's and my built .exe, then build it and sign the installer?

mermaid avatar Apr 19 '16 02:04 mermaid

I have started work to use https://github.com/kevinsawicki/signcode in the electron-builder (PR will be in this package, of course).

develar avatar Apr 19 '16 07:04 develar

@mermaid Don't reinvent the wheel. Just use electron-builder — https://github.com/electron-userland/electron-builder/issues/314#issuecomment-212269472

Fixed in my fork/electron-builder — PR will be this/next week.

develar avatar Apr 20 '16 05:04 develar

@develar It's a good question though. I'm wondering if all the .exe files need to be signed, or not?

feross avatar Apr 20 '16 05:04 feross

@feross Answered in linked comment — "electron-builder uses signcode to sign app exe regardless of Squirrel.Windows" Yes, you should sign app exe as well. Maybe no one force you to do it, but you should.

develar avatar Apr 20 '16 06:04 develar

@develar Shouldn't the .dlls also be signed?

feross avatar Apr 20 '16 06:04 feross

@feross http://stackoverflow.com/a/4716079 But only @kevinsawicki or @paulcbetts can answer as experts.

develar avatar Apr 20 '16 06:04 develar

@feross You can but it doesn't really make a difference to AV. You should sign your executables, including Squirrel.exe which is hard to do by signing yourself, which is why Squirrel has it built-in as part of its packager.

anaisbetts avatar Apr 20 '16 19:04 anaisbetts

electron-builder since 3.20 (will be released soon) will correctly sign your app — dual code sign (sha1+sha256) + timestamp (by default windows-installer on Windows sign using sha1 without timestamp).

Sorry, I am not going to prepare PR since intermediate https://github.com/electron/windows-installer/pull/77 is rejected and I don't want to waste my time and resolve merge conflicts. Anyway solution mostly implemented as part of signcode npm module (PR will be if https://github.com/kevinsawicki/signcode/issues/4)

develar avatar May 11 '16 10:05 develar

@kevinsawicki We still want to use your signcode package when we're on non-Windows platforms, right?

@develar Is your PR https://github.com/electron/windows-installer/pull/77 required for signcode integration? Seems like an unrelated issue, no?

feross avatar May 17 '16 22:05 feross

We still want to use your signcode package when we're on non-Windows platforms, right?

Yup, currently it only works on Mac, but Linux support should be straightforward, just haven't added it yet.

kevinsawicki avatar May 17 '16 22:05 kevinsawicki

For all the Googlers ending up in this issue looking for a solution, I've built a dirty workaround that gets the job done. https://github.com/dustinblackman/mono-signtool

dustinblackman avatar Dec 11 '16 19:12 dustinblackman

Just landed here trying to sign my Windows electron application that's being built on my macOS dev machine. @dustinblackman's workaround seems to sidestep the problem but I'm curious if anything was merged into either this repo or electron-builder to support signing Windows builds on macOS.

weedgrease avatar Feb 23 '17 16:02 weedgrease

electron-builder supports codesign on all platforms, including Linux. The only limitation — EV certificate on smartcards not supported.

develar avatar Feb 23 '17 16:02 develar

cheeky bump

mavrick avatar Mar 28 '17 10:03 mavrick

So, I managed to get around this on Ubuntu 16.04 with a manual sign step using osslsigncode

I'm only signing the .exe and not the contents.

mavrick avatar May 30 '17 10:05 mavrick

Looking at the thread, it looks like we can drop https://github.com/kevinsawicki/signcode here to support windows code-signing from non-windows from a Mac. Is that correct? Is there any known blocker for that?

(Or use electron-builder indeed)

alexstrat avatar Jun 15 '17 16:06 alexstrat

You can sign exe file in macos using jsign, which is basically java version of Microsoft Authenticode. I had to spend my afternoon for this. Hope this helps.

java -jar bin/lib/jsign/jsign-4.2.jar \
  --storetype PKCS12 \
  --keystore ???.pfx \
  --tsaurl http://timestamp.sectigo.com \
  --alias '???' \
  --storepass '???' \
  "out/make/squirrel.windows/x64/???.exe"
  • https://www.electron.build/tutorials/code-signing-windows-apps-on-unix.html#signing-windows-app-on-maclinux-using-jsign
  • https://github.com/ebourg/jsign/releases

danishin avatar Jan 23 '23 10:01 danishin

Hi @feross, do you have any idea on how to codesign the electron application in circleci for mac build ?

reddybhavanish avatar Dec 27 '23 13:12 reddybhavanish