YehudaKremer / msix

Create Msix installer for flutter windows-build files.
https://pub.dev/packages/msix
MIT License
277 stars 69 forks source link

Fix using SignTool options #156

Closed YehudaKremer closed 1 year ago

YehudaKremer commented 1 year ago

Hello @zobo

In this PR I'm trying to fix problems with SignTool.

this PR includes the changes:

  1. user can use SignTool freely as the office documentation instructing
  2. when trying to sign with an installed certificate by using one of the options '/n', '/i' and '/sha1', this package will try to extract the certificate Subject with PowerShell script you provided

About .crt, I don't think SignTool supports .crt files, if I am wrong can you please provide me an example, thanks.

I would appreciate it if you could go through the changes in your spare time 👍

zobo commented 1 year ago

The PR looks good, indeed the simple split by space caused issues when I was experimenting. I like the use of extensions.

Regarding CRT. The docs say:

/f SignCertFile Specifies the signing certificate in a file. If the file is in Personal Information Exchange (PFX) format and protected by a password, use the /p option to specify the password. If the file does not contain private keys, use the /csp and /kc options to specify the CSP and private key container name.

My experience is that if I provide a .crt file, the SignTool will figure out what private key to use. I did not need to add /csp and /kc options.

I'd suggest to also look for the case where a certificate file is provided, but no password and then extract the subject via: new-object System.Security.Cryptography.X509Certificates.X509Certificate2("..\file.crt") | select -expandproperty Subject -First 1

I'll try to provide the code, but I'll be leaving for a week of travel soon.

YehudaKremer commented 1 year ago

Good notes and examples, I will add them to this branch soon as possible.

Thank You! 👍

YehudaKremer commented 1 year ago

Hello @zobo

I publish a new version (3.7.0) with these changes:

Thank you!

zobo commented 1 year ago

Looks like everything is working great. Thank you again!