Skip to content

Commit 999494b

Browse files
committed
Add .cmd to sign the WIC DLL and installer
To make it possible to code sign, extend the projects with signing targets. Provide a .cmd file to build and sign all release builds. The current setup supports certificates stored on a smart card.
1 parent 96dc66a commit 999494b

8 files changed

+80
-1
lines changed

CHANGELOG.md

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# Changelog
2+
3+
All notable changes to this project will be documented in this file.
4+
5+
The format is based on [Keep a Changelog](http://keepachangelog.com/) and this project adheres to [Semantic Versioning](http://semver.org/).
6+
7+
## [Unreleased]
8+
9+
## [0.2.0 - 2024-10-8]
10+
11+
### Added
12+
13+
- Initial release.

Directory.Build.props

+5
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,11 @@
3535

3636
<AccelerateBuildsInVisualStudio>true</AccelerateBuildsInVisualStudio><!-- Enable faster builds for SDK style projects in Visual Studio 2022 17.5 and newer. -->
3737
<ManagePackageVersionsCentrally>true</ManagePackageVersionsCentrally>
38+
39+
<_CertificateThumbprint>$(CertificateThumbprint)</_CertificateThumbprint>
40+
<_CertificateThumbprint Condition="'$(_CertificateThumbprint)' == ''">b834c6c1d7e0ae8e76cadcf9e2e7a273133a5df6</_CertificateThumbprint>
41+
<_TimestampUrl>$(TimestampUrl)</_TimestampUrl>
42+
<_TimestampUrl Condition="'$(_TimestampUrl)' == ''">http://time.certum.pl/</_TimestampUrl>
3843
</PropertyGroup>
3944

4045
<ItemDefinitionGroup>

README.md

+14-1
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ Go to the [releases](https://github.com/team-charls/netpbm-wic-codec/releases) p
4949
Assets at the bottom to show the files available in the release.
5050
Please use the appropriate installer that matches your machine's architecture.
5151

52-
### Applications that can use the Netpbm WIC codec
52+
## Applications that can use the Netpbm WIC codec
5353

5454
The following application have been validated to work with the Netpbm WIC codec:
5555

@@ -123,3 +123,16 @@ regsvr32 netpbm-wic-codec.dll
123123
```shell
124124
regsvr32 -u netpbm-wic-codec.dll
125125
```
126+
127+
### Building and code signing
128+
129+
A command file is available to build and sign the WIC DLL and the setup application.
130+
Instructions:
131+
132+
* Open a Visual Studio Developer Command Prompt
133+
* Go the root of the cloned repository
134+
* Ensure a code signing certificate is available
135+
* Execute the command `create-signed-builds.cmd certificate-thumb-print time-stamp-url`
136+
Note: the certificate thumbprint and time stamp URL arguments are depending on the used code signing certificate.
137+
138+
The WIC DLL and the installer will be signed for the release builds of x86, x64 and ARM64.

SECURITY.md

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# Security Policy
2+
3+
## Supported Versions
4+
5+
| Version | Supported |
6+
| ------- | ------------------ |
7+
| 0.2.0 | :white_check_mark: |
8+
9+
## Reporting a Vulnerability
10+
11+
Security issues should be reported privately by creating a security advisory on GitHub.
12+
13+
Please do not open a public issue for anything you think might have a security implication.

create-signed-builds.cmd

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# Build signed x86
2+
msbuild -t:clean -p:Configuration=Release -p:Platform=x86
3+
msbuild -t:restore -p:Configuration=Release -p:Platform=x86
4+
msbuild -t:build -p:Configuration=Release -p:Platform=x86 -p:SignOutput=true -p:CertificateThumbprint=%1 -p:TimestampUrl=%2
5+
6+
# Build signed x64
7+
msbuild -t:clean -p:Configuration=Release -p:Platform=x64
8+
msbuild -t:restore -p:Configuration=Release -p:Platform=x64
9+
msbuild -t:build -p:Configuration=Release -p:Platform=x64 -p:SignOutput=true -p:CertificateThumbprint=%1 -p:TimestampUrl=%2
10+
11+
# Build signed ARM64
12+
msbuild -t:clean -p:Configuration=Release -p:Platform=ARM64
13+
msbuild -t:restore -p:Configuration=Release -p:Platform=ARM64
14+
msbuild -t:build -p:Configuration=Release -p:Platform=ARM64 -p:SignOutput=true -p:CertificateThumbprint=%1 -p:TimestampUrl=%2
15+

setup/bootstrapper/bootstrapper.wixproj

+10
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,14 @@
1717
<ItemGroup>
1818
<ProjectReference Include="..\installer\installer.wixproj" />
1919
</ItemGroup>
20+
21+
<Target Name="SignBundleEngine">
22+
<Message Importance="high" Text="SignBundleEngine: @(SignBundleEngine)" />
23+
<Exec Command='signtool.exe sign /fd SHA256 /td SHA256 /v /sha1 $(_CertificateThumbprint) /tr $(_TimestampUrl) "%(SignBundleEngine.FullPath)" ' />
24+
</Target>
25+
26+
<Target Name="SignBundle">
27+
<Message Importance="high" Text="SignBundle: @(SignBundle)" />
28+
<Exec Command='signtool.exe sign /fd SHA256 /td SHA256 /v /sha1 $(_CertificateThumbprint) /tr $(_TimestampUrl) "%(SignBundle.FullPath)" ' />
29+
</Target>
2030
</Project>

setup/installer/installer.wixproj

+5
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,9 @@
1212
<ItemGroup>
1313
<ProjectReference Include="..\..\src\netpbm-wic-codec.vcxproj" />
1414
</ItemGroup>
15+
16+
<Target Name="SignMsi">
17+
<Message Importance="high" Text="SignMsi: @(SignMsi)" />
18+
<Exec Command='signtool.exe sign /fd SHA256 /td SHA256 /v /sha1 $(_CertificateThumbprint) /tr $(_TimestampUrl) "%(SignMsi.FullPath)" ' />
19+
</Target>
1520
</Project>

src/netpbm-wic-codec.vcxproj

+5
Original file line numberDiff line numberDiff line change
@@ -228,4 +228,9 @@
228228
<Error Condition="!Exists('..\packages\Microsoft.Windows.CppWinRT.2.0.240405.15\build\native\Microsoft.Windows.CppWinRT.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Microsoft.Windows.CppWinRT.2.0.240405.15\build\native\Microsoft.Windows.CppWinRT.props'))" />
229229
<Error Condition="!Exists('..\packages\Microsoft.Windows.CppWinRT.2.0.240405.15\build\native\Microsoft.Windows.CppWinRT.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Microsoft.Windows.CppWinRT.2.0.240405.15\build\native\Microsoft.Windows.CppWinRT.targets'))" />
230230
</Target>
231+
<Target Name="SignWindowsDlls" AfterTargets="Build" Condition="'$(SignOutput)'=='true'">
232+
<!-- Use TargetFrameworkVersion=v4.5 to sign with SHA256 -->
233+
<Message Text="Signing netpbm-wic-codec.dll" />
234+
<SignFile CertificateThumbprint="$(_CertificateThumbprint)" TimestampUrl="$(_TimestampUrl)" SigningTarget="$(OutputPath)netpbm-wic-codec.dll" TargetFrameworkVersion="v4.5" />
235+
</Target>
231236
</Project>

0 commit comments

Comments
 (0)