@@ -19,35 +19,41 @@ echo on
1919
2020if %SIGN% == 0 goto NoSign
2121
22+ REM commands to sign
23+
2224set signtoolWin11 = " C:\Program Files (x86)\Windows Kits\10\bin\10.0.22621.0\x64\signtool.exe"
23- set signBinary = %signtoolWin11% sign /fd SHA512 /tr http://timestamp.acs.microsoft.com /td sha512 /a /f %NPP_CERT% /p %NPP_CERT_PWD% /d " Notepad++" /du https://notepad-plus-plus.org/
2425
25- REM macro is used to sign NppShell.dll & NppShell.msix with hash algorithm SHA256, due to signtool.exe bug:
26- REM https://learn.microsoft.com/en-us/windows/msix/package/signing-known-issues
27- set signBinarySha256 = %signtoolWin11% sign /fd SHA256 /tr http://timestamp.acs.microsoft.com /td sha512 /a /f %NPP_CERT% /p %NPP_CERT_PWD% /d " Notepad++" /du https://notepad-plus-plus.org/
26+ set Sign_by_NppRootCert = %signtoolWin11% sign /fd SHA512 /tr http://timestamp.acs.microsoft.com /td sha512 /a /f %NPP_CERT% /p %NPP_CERT_PWD% /d " Notepad++" /du https://notepad-plus-plus.org/
2827
28+ set Sign_by_GlobalSignCert = %signtoolWin11% sign /n " NOTEPAD++" /tr http://timestamp.globalsign.com/tsa/r6advanced1 /td SHA256 /fd SHA256
2929
30- set baseBinaries = ..\bin\notepad++.exe ..\bin64\notepad++.exe ..\binarm64\notepad++.exe ..\bin\plugins\Config\nppPluginList.dll ..\bin64\plugins\Config\nppPluginList.dll ..\binarm64\plugins\Config\nppPluginList.dll ..\bin\updater\GUP.exe ..\bin64\updater\GUP.exe ..\binarm64\updater\GUP.exe ..\bin\updater\libcurl.dll ..\bin64\updater\libcurl.dll ..\binarm64\updater\libcurl.dll ..\bin\plugins\NppExport\NppExport.dll ..\bin64\plugins\NppExport\NppExport.dll ..\binarm64\plugins\NppExport\NppExport.dll ..\bin\plugins\mimeTools\mimeTools.dll ..\bin64\plugins\mimeTools\mimeTools.dll ..\binarm64\plugins\mimeTools\mimeTools.dll ..\bin\plugins\NppConverter\NppConverter.dll ..\bin64\plugins\NppConverter\NppConverter.dll ..\binarm64\plugins\NppConverter\NppConverter.dll
30+ set DOUBLE_SIGNING = /as
3131
32- %signBinary% %baseBinaries%
33- If ErrorLevel 1 goto End
32+ REM files to be signed
3433
34+ set nppBinaries = ..\bin\notepad++.exe ..\bin64\notepad++.exe ..\binarm64\notepad++.exe
3535
36- REM %signBinarySha256% ..\bin\NppShell.x86.dll
37- REM If ErrorLevel 1 goto End
38- REM
39- REM %signBinarySha256% ..\bin64\NppShell.msix
40- REM If ErrorLevel 1 goto End
41- REM %signBinarySha256% ..\bin64\NppShell.x64.dll
42- REM If ErrorLevel 1 goto End
43- REM
44- REM %signBinarySha256% ..\binarm64\NppShell.msix
45- REM If ErrorLevel 1 goto End
46- REM %signBinarySha256% ..\binarm64\NppShell.arm64.dll
47- REM If ErrorLevel 1 goto End
36+ set componentsBinaries = ..\bin\plugins\Config\nppPluginList.dll ..\bin64\plugins\Config\nppPluginList.dll ..\binarm64\plugins\Config\nppPluginList.dll ..\bin\updater\GUP.exe ..\bin64\updater\GUP.exe ..\binarm64\updater\GUP.exe ..\bin\updater\libcurl.dll ..\bin64\updater\libcurl.dll ..\binarm64\updater\libcurl.dll
4837
38+ set pluginBinaries = ..\bin\plugins\NppExport\NppExport.dll ..\bin64\plugins\NppExport\NppExport.dll ..\binarm64\plugins\NppExport\NppExport.dll ..\bin\plugins\mimeTools\mimeTools.dll ..\bin64\plugins\mimeTools\mimeTools.dll ..\binarm64\plugins\mimeTools\mimeTools.dll ..\bin\plugins\NppConverter\NppConverter.dll ..\bin64\plugins\NppConverter\NppConverter.dll ..\binarm64\plugins\NppConverter\NppConverter.dll
4939
5040
41+ REM macro is used to sign NppShell.dll & NppShell.msix with hash algorithm SHA256, due to signtool.exe bug:
42+ REM "error 0x8007000B: The signature hash method specified (SHA512) must match the hash method used in the app package block map (SHA256)."
43+ REM "The hashAlgorithm specified in the /fd parameter is incorrect. Rerun SignTool using hashAlgorithm that matches the app package block map (used to create the app package)"
44+ REM Note that Publisher in Packaging/AppxManifest.xml should match with the Subject of certificate.
45+ REM https://learn.microsoft.com/en-us/windows/msix/package/signing-known-issues
46+ set nppShellBinaries = ..\bin\NppShell.x86.dll ..\bin64\NppShell.msix ..\bin64\NppShell.x64.dll ..\binarm64\NppShell.msix ..\binarm64\NppShell.arm64.dll
47+
48+ %Sign_by_NppRootCert% %nppBinaries% %componentsBinaries% %pluginBinaries%
49+ If ErrorLevel 1 goto End
50+
51+ %Sign_by_GlobalSignCert% %DOUBLE_SIGNING% %nppBinaries% %componentsBinaries% %pluginBinaries%
52+ If ErrorLevel 1 goto End
53+
54+ %Sign_by_GlobalSignCert% %nppShellBinaries%
55+ If ErrorLevel 1 goto End
56+
5157
5258:NoSign
5359
@@ -506,7 +512,10 @@ ren npp.portable.minimalist.x64.7z !7zvarMin64!
506512ren npp.portable.minimalist.arm64.7z !7zvarMinArm64!
507513
508514if %SIGN% == 0 goto NoSignInstaller
509- %signBinary% !nppInstallerVar! !nppInstallerVar64! !nppInstallerVarArm64!
515+
516+ %Sign_by_NppRootCert% !nppInstallerVar! !nppInstallerVar64! !nppInstallerVarArm64!
517+
518+ %Sign_by_GlobalSignCert% %DOUBLE_SIGNING% !nppInstallerVar! !nppInstallerVar64! !nppInstallerVarArm64!
510519
511520:NoSignInstaller
512521
0 commit comments