Skip to content

Commit 0b88c53

Browse files
dpageakshay-joshi
authored andcommitted
Update Windows code signing to work with new hardware key (or none) (pgadmin-org#9483)
1 parent 97cd009 commit 0b88c53

File tree

1 file changed

+28
-9
lines changed

1 file changed

+28
-9
lines changed

Make.bat

Lines changed: 28 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ REM Main build sequence Ends
5959
IF "%PGADMIN_VCREDIST_DIR%" == "" SET "PGADMIN_VCREDIST_DIR=C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Redist\MSVC\14.40.33807"
6060
IF "%PGADMIN_VCREDIST_FILE%" == "" SET "PGADMIN_VCREDIST_FILE=vc_redist.x64.exe"
6161
IF "%PGADMIN_SIGNTOOL_DIR%" == "" SET "PGADMIN_SIGNTOOL_DIR=C:\Program Files (x86)\Windows Kits\10\bin\10.0.22621.0\x64"
62+
IF "%PGADMIN_WINDOWS_CSC%" == "" SET "PGADMIN_WINDOWS_CSC="
6263

6364
REM Set additional variables we need
6465
FOR /F "tokens=3" %%a IN ('findstr /C:"APP_RELEASE =" %WD%\web\version.py') DO SET APP_MAJOR=%%a
@@ -99,6 +100,11 @@ REM Main build sequence Ends
99100
ECHO VC++ redist file: %PGADMIN_VCREDIST_FILE%
100101
ECHO InnoTool directory: %PGADMIN_INNOTOOL_DIR%
101102
ECHO signtool directory: %PGADMIN_SIGNTOOL_DIR%
103+
IF "%PGADMIN_WINDOWS_CSC%" == "" (
104+
ECHO Code signing certificate: [NONE - Signing disabled]
105+
) ELSE (
106+
ECHO Code signing certificate: %PGADMIN_WINDOWS_CSC%
107+
)
102108
ECHO.
103109
ECHO App version: %APP_VERSION%
104110
ECHO App version suffix: %APP_VERSION_SUFFIX%
@@ -306,14 +312,18 @@ REM Main build sequence Ends
306312
%TMPDIR%\rcedit-x64.exe "%BUILDROOT%\runtime\pgAdmin4.exe" --set-version-string "ProductName" "%APP_NAME%"
307313
%TMPDIR%\rcedit-x64.exe "%BUILDROOT%\runtime\pgAdmin4.exe" --set-product-version "%APP_VERSION%""
308314

309-
ECHO Attempting to sign the pgAdmin4.exe...
310-
CALL "%PGADMIN_SIGNTOOL_DIR%\signtool.exe" sign /fd certHash /tr http://timestamp.digicert.com /td SHA256 "%BUILDROOT%\runtime\pgAdmin4.exe"
311-
IF %ERRORLEVEL% NEQ 0 (
312-
ECHO.
313-
ECHO ************************************************************
314-
ECHO * Failed to sign the pgAdmin4.exe
315-
ECHO ************************************************************
316-
PAUSE
315+
IF NOT "%PGADMIN_WINDOWS_CSC%" == "" (
316+
ECHO Attempting to sign the pgAdmin4.exe...
317+
CALL "%PGADMIN_SIGNTOOL_DIR%\signtool.exe" sign /sm /n "%PGADMIN_WINDOWS_CSC%" /tr http://timestamp.digicert.com /td sha256 /fd sha1 /v "%BUILDROOT%\runtime\pgAdmin4.exe"
318+
IF %ERRORLEVEL% NEQ 0 (
319+
ECHO.
320+
ECHO ************************************************************
321+
ECHO * Failed to sign the pgAdmin4.exe
322+
ECHO ************************************************************
323+
PAUSE
324+
)
325+
) ELSE (
326+
ECHO Skipping code signing ^(PGADMIN_WINDOWS_CSC is not set^)...
317327
)
318328

319329
ECHO Staging PostgreSQL components...
@@ -356,7 +366,11 @@ REM Main build sequence Ends
356366
DEL /s "%WD%\pkg\win32\installer.iss.in_stage*" > nul
357367

358368
ECHO Creating windows installer using INNO tool...
359-
CALL "%PGADMIN_INNOTOOL_DIR%\ISCC.exe" "%WD%\pkg\win32\installer.iss" "/SpgAdminSigntool=%PGADMIN_SIGNTOOL_DIR%\signtool.exe sign /fd certHash /tr http://timestamp.digicert.com /td SHA256 $f" || EXIT /B 1
369+
IF NOT "%PGADMIN_WINDOWS_CSC%" == "" (
370+
CALL "%PGADMIN_INNOTOOL_DIR%\ISCC.exe" "%WD%\pkg\win32\installer.iss" "/SpgAdminSigntool=%PGADMIN_SIGNTOOL_DIR%\signtool.exe sign /sm /n $q%PGADMIN_WINDOWS_CSC%$q /tr http://timestamp.digicert.com /td sha256 /fd sha1 /v $f" || EXIT /B 1
371+
) ELSE (
372+
CALL "%PGADMIN_INNOTOOL_DIR%\ISCC.exe" "%WD%\pkg\win32\installer.iss" || EXIT /B 1
373+
)
360374

361375
ECHO Renaming installer...
362376
MOVE "%WD%\pkg\win32\Output\pgadmin4-setup.exe" "%DISTROOT%\%INSTALLERNAME%" > nul || EXIT /B 1
@@ -374,6 +388,11 @@ REM Main build sequence Ends
374388
EXIT /B 0
375389

376390
:VERIFY_SIGNATURE
391+
IF "%PGADMIN_WINDOWS_CSC%" == "" (
392+
ECHO Skipping signature verification ^(PGADMIN_WINDOWS_CSC is not set^)...
393+
EXIT /B 0
394+
)
395+
377396
ECHO Verifying the installer signature...
378397

379398
CALL "%PGADMIN_SIGNTOOL_DIR%\signtool.exe" verify /pa /v "%DISTROOT%\%INSTALLERNAME%"

0 commit comments

Comments
 (0)