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

Can't specify hash algorithm for the Sign command #906

Closed
thomaslevesque opened this issue May 20, 2016 · 4 comments
Closed

Can't specify hash algorithm for the Sign command #906

thomaslevesque opened this issue May 20, 2016 · 4 comments
Milestone

Comments

@thomaslevesque
Copy link
Contributor

There are no properties in SignToolSignSettingsto specify:

  • the use of a RFC 3161 timestamp server (/tr instead of /t)
  • the digest algorithm to use for the signature (/fd)
  • the digest algorithm to use for the timestamp (/td)

Worse, it's also not possible to use ArgumentCustomization to add these settings manually, because all options must come before all file arguments. If they're added at the end, SignTool treats them as files, which of course don't exist.

Suggested solution :

  • a UseRfc3161TimestampServer property in SignToolSignSettings to control whether /t or /tr is used
  • A SignatureDigestAlgorithm to control the /fd option
  • A TimestampDigestAlgorithm to control the /td option

OR

A way to insert options before the file names with ArgumentCustomization. I suspect it would be more complex, since this is handled in the Tool<TSettings> base class.

@devlead
Copy link
Member

devlead commented May 20, 2016

@thomaslevesque yes this would be nice, good feedback.

FYI though, meanwhile you actually can use ArgumentCustomization it's a Func<ProcessArgumentBuilder,​ ProcessArgumentBuilder> so you could just ignore what comes in and replace it.

Example cake script, this is 2 min thrown together so not correct but hopefully you get the gist of it.

FilePath assembly = File("assembly.dll");

SignToolSignSettings settings;
settings = new SignToolSignSettings
            {
                ArgumentCustomization = args => new ProcessArgumentBuilder()
                                                    .Append("SIGN")
                                                    .AppendSwitchQuoted("/tr", settings.TimeStampUri.AbsoluteUri)
                                                    .AppendSwitchQuoted("/sha1", settings.CertThumbprint)
                                                    .Append("/fd")
                                                    .Append("/td")
                                                    .AppendQuoted(assembly.MakeAbsolute(Context.Environment).FullPath),
                TimeStampUri = new Uri("http://localhost"),
                CertThumbprint ="0101010010101001"
            };
Sign(
    assembly,
    settings
    );

This will ouptut something like
SIGN /tr "http://localhost/" /sha1 "http://localhost/" /fd /td "C:/temp/assembly.dll"

While testing things you can even to hacky things like ArgumentCustomization = args => args.Render().Replace("SIGN /t", "SIGN /tr")

@thomaslevesque
Copy link
Contributor Author

FYI though, meanwhile you actually can use ArgumentCustomization it's a Func<ProcessArgumentBuilder,​ ProcessArgumentBuilder> so you could just ignore what comes in and replace it.

True, but it's equivalent to redoing most of the work done by SignToolSignRunner, so at this point I might as well just use StartProcess directly 😉
(which is what I'm doing now)

@devlead
Copy link
Member

devlead commented May 20, 2016

Well you get tool resolution and validation of known parameters so a little more than just StartProcess 😉

@thomaslevesque
Copy link
Contributor Author

Fixed by #1308

@gep13 gep13 added this to the v0.17.0 milestone Oct 28, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants