-
Notifications
You must be signed in to change notification settings - Fork 8.1k
Add missing timestamper cert to the newer catalog signing APIs #4061
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
Conversation
…alog signing APIs
| } | ||
| } | ||
|
|
||
| Diagnostics.Assert(((error == 0) && (signature != null)) || (error != 0), "GetSignatureFromWintrustData: general crypto failure"); |
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.
Question about this case, will sync offline
| } | ||
|
|
||
| [ArchitectureSensitive] | ||
| private static bool TryGetProviderSigner(IntPtr wvtStateData, ref IntPtr pProvSigner, ref X509Certificate2 timestamperCert) |
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.
It seems to me both pProvSigner and timestamperCert are better to be an out parameter instead of a ref parameter.
| else | ||
| { | ||
| signature = new Signature(filename, error, cert); | ||
| } |
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.
Once the parameters pProvSigner and timestamperCert are changed to out parameters, you can use the new language feature in C# for out parameters:
if (int.TryParse(input, out int result))
WriteLine(result);
else
WriteLine("Could not parse input");So this code block can be rewritten to:
if (TryGetProviderSigner(phStateData, out IntPtr pProvSigner, out X509Certificate2 timestamperCert) && timestamperCert != null)
{
signature = new Signature(filename, error, cert, timestamperCert);
}
else
{
signature = new Signature(filename, error, cert);
}| X509Certificate2 signerCert = null; | ||
| IntPtr pProvSigner = IntPtr.Zero; | ||
| X509Certificate2 timestamperCert = null; | ||
| if (TryGetProviderSigner(wtd.hWVTStateData, ref pProvSigner, ref timestamperCert)) |
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.
Same here. Once change to out parameters, you can use the new feature in C# to make the code cleaner.
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.
Good idea. Will change.
|
I created issue #4087 to document the lack of tests |
|
@mirichmo Is there anything preventing this from being merged? I also need to port this to internal branches. Thanks! |
This fixes Issue #4060
Code to obtain the file signature time stamp cert was missing from the newer catalog signing APIs, with the result that Get-AuthenticodeSignature would not include the time stamp cert in the Signature object.
Fix is to refactor and use the older API code for obtaining this.
I didn't add a test for this because no catalog signing tests are in GitHub yet and porting them will be a separate work item.