Skip to content
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

Signing MSI attempts dual signing and fails #181

Open
AdamPD opened this issue Mar 25, 2024 · 7 comments
Open

Signing MSI attempts dual signing and fails #181

AdamPD opened this issue Mar 25, 2024 · 7 comments

Comments

@AdamPD
Copy link

AdamPD commented Mar 25, 2024

Since the change in #177 to use @electron/windows-sign, the package now tries to dual sign the MSI with both SHA-1 and SHA-256 (which fails):

Error: Signtool exited with code 1. Stderr: SignTool Error: Multiple signature support is not implemented for this filetype.

@electron/windows-sign needs to be able to specify that only a single algorithm is required, and then this package should specify which one to use.

@PeteAUK
Copy link

PeteAUK commented Mar 26, 2024

I've just updated to the latest version of everything and getting exactly the same error. Digging into it and trying a plethora of
approaches and I think this is an issue more relating to windows-sign and MSI's than anything else. I've even tried multiple versions of signtool.exe to see if that made any difference (which it didn't).

On my Windows 10 machine the only way I've got this working is to set appendSignature to false on line 106 of cjs/signWithSignTool.js - it's a hack and not something I'd necessarily recommend. It also explains why the old way of doing it didn't break, because that flag adds the /as argument onto the signtool.exe command which is where the error comes from.

Don't quite know if this varies depending on the operating system being used as it's a weird one to have slipped through.

@zkrige
Copy link

zkrige commented Oct 1, 2024

its because electron/windows-sign appends signatures -

https://github.com/electron/windows-sign/blob/7527ffff6158ad7b4062e112c448a862f185034d/src/sign-with-signtool.ts#L123

I'm also looking for a way to disable this

there is a PR for it

electron/windows-sign#19

@AndreyApalkov
Copy link

want to bump this issue since currently MSI signing is not working.

@alu-
Copy link

alu- commented Oct 31, 2024

Running in to this as well. Are there any workarounds?

@AndreyApalkov
Copy link

@alu- I got around this by using hookFunction:

{
        windowsSign: {
          hookFunction: async (fileToSign: string) => {
            const {
              code,
              stderr,
              stdout,
            }: {code: number | null; stderr: string; stdout: string} =
              await new Promise(resolve => {
                const command = process.env.SIGNTOOL_PATH ?? '';
                const hash = 'sha256';
                const args = [
                  'sign',
                  '/tr',
                  process.env.TIMESTAMP_SERVER ?? '',
                  '/td',
                  hash,
                  '/f',
                  process.env.CODE_SIGNING_CERTIFICATE_PATH ?? '',
                  '/p',
                  process.env.CODE_SIGNING_PASSWORD ?? '',
                  '/fd',
                  hash,
                  fileToSign,
                ];
                const fork = spawn(command, args, {
                  env: process.env,
                  cwd: process.cwd(),
                });
                let stdout = '';
                let stderr = '';
                fork.stdout.on('data', data => {
                  stdout += data;
                });
                fork.stderr.on('data', data => {
                  stderr += data;
                });
                fork.on('close', code => {
                  resolve({stdout, stderr, code});
                });
              });

            if (code !== 0) {
              console.error(
                `Signtool exited with code ${code}. Stderr: ${stderr}. Stdout: ${stdout}`,
              );
              // eslint-disable-next-line no-process-exit
              process.exit(1);
            }
          },
        },
// ... other properties
      },

@alu-
Copy link

alu- commented Oct 31, 2024

Yay! Using the above mentioned hookFunction did indeed work for me after some customization. Thank you very much Andrey.

For any that comes after I forgot to remove the old references to certificateFile which caused the same error as it tried to sign the file twice, but after I removed that it works.

@zkrige
Copy link

zkrige commented Nov 29, 2024

this PR has been accepted. These options need to be brought forward into this package

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants