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

feat: support skipping SHA1 signing #19

Merged
merged 4 commits into from
Nov 5, 2024
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,8 @@ description = "My content"
website = "https://mywebsite.com"
// If enabled, attempt to sign .js JavaScript files. Disabled by default
signJavaScript = true
// If unspecified, both sha1 and sha256 signatures will be appended. Will be passed to signtool.exe as the /fd option.
hashes = ["sha256"]
```

## With a custom signtool.exe or custom parameters
Expand Down
13 changes: 11 additions & 2 deletions src/sign-with-signtool.ts
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,15 @@ export async function signWithSignTool(options: InternalSignOptions) {
website
};

await execute({ ...internalOptions, hash: HASHES.sha1 });
await execute({ ...internalOptions, hash: HASHES.sha256, appendSignature: true });
const hashes =
options.hashes == null || options.hashes.length === 0
? [HASHES.sha1, HASHES.sha256]
: options.hashes;

if (hashes.includes(HASHES.sha1)) {
await execute({ ...internalOptions, hash: HASHES.sha1 });
}
if (hashes.includes(HASHES.sha256)) {
await execute({ ...internalOptions, hash: HASHES.sha256, appendSignature: true });
mceachen marked this conversation as resolved.
Show resolved Hide resolved
}
}
4 changes: 4 additions & 0 deletions src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,10 @@ export interface OptionalSignToolOptions {
* @defaultValue false
*/
signJavaScript?: boolean;
/**
* Hash algorithms to use for signing.
*/
hashes?: HASHES[];
}

/**
Expand Down