Skip to content

Commit

Permalink
Windows trusted code signing
Browse files Browse the repository at this point in the history
  • Loading branch information
Shchvova committed Feb 9, 2025
1 parent bebe3d0 commit f949773
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 50 deletions.
10 changes: 9 additions & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -592,6 +592,12 @@ jobs:
run: |
curl -sL https://github.com/coronalabs/binary-data/releases/download/1.0/redist.win32.7z -o redist.win32.7z
7z x redist.win32.7z -o"platform/windows/Bin/redist" -y
- name: Install Codesigning Tools:
shell: cmd
run: |
choco install dotnet-8.0-runtime --no-progress
nuget install Microsoft.Windows.SDK.BuildTools -Version 10.0.22621.3233 -x
nuget install Microsoft.Trusted.Signing.Client -Version 1.0.53 -x
- name: Build Corona Simulator
shell: cmd
run: |
Expand All @@ -601,7 +607,9 @@ jobs:
call "C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC\Auxiliary\Build\vcvars32.bat"
devenv "Corona.SDK.sln" /rebuild "Release|x86"
env:
WIN_CERT_PASSWORD: ${{ secrets.WinCertPassword }}
AZURE_TENANT_ID: ${{ secrets.AZURE_TENANT_ID }}
AZURE_CLIENT_ID: ${{ secrets.AZURE_CLIENT_ID }}
AZURE_CLIENT_SECRET: ${{ secrets.AZURE_CLIENT_SECRET }}
- name: Copy Simulator
run: |
mkdir output
Expand Down
47 changes: 6 additions & 41 deletions platform/windows/Build.Tools/CoronaLabsInc.Sign.bat
Original file line number Diff line number Diff line change
@@ -1,51 +1,16 @@
@echo off
@echo on
REM ---------------------------------------------------------------------------------------
REM Batch file used to digitally sign a given file with Corona Labs' certificate.
REM Sign a given file with Solar2D certificate.
REM ---------------------------------------------------------------------------------------

if NOT EXIST "%~dp0CoronaLabsInc.pfx" goto :OnSkipSigning
if "%WIN_CERT_PASSWORD%"=="" goto :OnSkipSigning
if "%AZURE_CLIENT_SECRET%"=="" goto :OnSkipSigning

REM Validate arguments. If incorrect, then echo out how to use this batch file.
if "%~1"=="" goto OnShowCommandLineHelp


REM Attempt to fetch the optional 2nd argument "Program Name".
if NOT "%~2"=="" set programNameArgument=/d "%~2"

REM Set up command line tools if not available
echo Setup command line
call "%~dp0VSVars.bat"

REM Digitally sign the given file.
echo Digitally signing file: %~1

signtool sign /fd sha1 /f "%~dp0CoronaLabsInc.pfx" /p "%WIN_CERT_PASSWORD%" /t http://timestamp.digicert.com %programNameArgument% "%~1"
if errorlevel 0 goto:eof
echo "Signin failed. Using fallback timestamp server 1!"
signtool sign /fd sha1 /f "%~dp0CoronaLabsInc.pfx" /p "%WIN_CERT_PASSWORD%" /t http://timestamp.verisign.com/scripts/timestamp.dll %programNameArgument% "%~1"
if errorlevel 0 goto:eof
echo "Signin failed. Using fallback timestamp server 2!"
signtool sign /fd sha1 /f "%~dp0CoronaLabsInc.pfx" /p "%WIN_CERT_PASSWORD%" /t http://timestamp.globalsign.com/scripts/timestamp.dll %programNameArgument% "%~1"
if errorlevel 0 goto:eof
echo "Signin failed. Using fallback timestamp server 3!"
signtool sign /fd sha1 /f "%~dp0CoronaLabsInc.pfx" /p "%WIN_CERT_PASSWORD%" /t http://tsa.starfieldtech.com %programNameArgument% "%~1"
if errorlevel 0 goto:eof
echo "Signin failed. Using fallback timestamp server 4!"
signtool sign /fd sha1 /f "%~dp0CoronaLabsInc.pfx" /p "%WIN_CERT_PASSWORD%" /t http://timestamp.geotrust.com/tsa %programNameArgument% "%~1"
if errorlevel 0 goto:eof
echo "NO TIMESTAMP FALLBACK WORKED!"
exit /b 1
goto:eof


:OnShowCommandLineHelp
echo Signs a given file with Corona Labs' digital certificate.
echo.
echo Usage: CoronaLabsInc.Sign.bat [FilePath] [ProgramName]
echo [FilePath] Path to the file that you want to digitally sign.
echo [ProgramName] Optional: Program name to be displayed in the UAC prompt.
exit /b 1
"%WORKSPACE%\Microsoft.Windows.SDK.BuildTools\bin\10.0.22621.0\x86\signtool.exe" sign /v /debug /fd SHA256 /tr "http://timestamp.acs.microsoft.com" /td SHA256 /dlib "%WORKSPACE%\Microsoft.Trusted.Signing.Client\bin\x86\Azure.CodeSigning.Dlib.dll" /dmdf "%WORKSPACE%/platform/windows/Build.Tools/solar2d.json" %programNameArgument% "%~1"
goto :End

:OnSkipSigning
echo Skipping singing becaues password or key is not found
:End
5 changes: 5 additions & 0 deletions platform/windows/Build.Tools/solar2d.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"Endpoint": "https://eus.codesigning.azure.net",
"CodeSigningAccountName": "Solar2D",
"CertificateProfileName": "Solar2D"
}
18 changes: 10 additions & 8 deletions platform/windows/README.md
Original file line number Diff line number Diff line change
@@ -1,18 +1,20 @@

# Building for Windows Desktop

## Prerequisites:

You must install the following before building Corona Labs' Win32 software.
- Visual Studio 2019 Community Edition
* Make sure to install C++ components for 140 toolset, as well as 141 CLI, ATL, MFC and XP Tools
- WiX Toolset v3.10 (Needed to build the install program)
* Installer can be found at: corona\tools\Wix

- [Visual Studio 2019 Community Edition](https://aka.ms/vs/16/release/vs_community.exe)
- Select Native Development workload
- Add individual components:
- C++ Windows XP Support for VS 2017 (v141) tools [Deprecated]
- C++ MFC for v141 build tools (x86 & x64)

## How to build "Corona Simulator":

- Double click on "Corona.Simulator.sln" file.
* Solution file is used to build and debug Corona Simulator software.
* Outputs to:

- Solution file is used to build and debug Corona Simulator software.
- Outputs to:

.\platform\windows\bin\Corona

0 comments on commit f949773

Please sign in to comment.