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

Codechange: [CI] Use Azure Code Signing for Windows build #12292

Merged
merged 1 commit into from Mar 19, 2024

Conversation

orudge
Copy link
Contributor

@orudge orudge commented Mar 13, 2024

Motivation / Problem

Our current code signing certificate is due for renewal in a few months, and due to recent policy changes by the Certificate Authority cabal, you now need to store a certificate on a pricey hardware dongle or a certified HSM vault. For something compatible with GitHub Actions, we'd probably need to use an Azure HSM vault, but would still need to pay several hundred GBP per year for a certificate, a considerable increase compared with what we've got just now.

However, the good folks at ImageMagick alerted me to a preview programme Microsoft is running, called Azure Code Signing. This offers a more Mac-like solution, with Microsoft providing a code signing certificate. I applied for us to join their preview programme, and was accepted. Currently, the preview is free; it's not yet clear when this will become generally available or what pricing may be involved, but one would hope it'll be considerably cheaper than the alternatives.

Description

This PR adds support for Azure Code Signing to the build process. To keep things fairly simple, I've created a sign_azure.bat script that acts as an alternative for sign.bat (which is called within the CMake process). Microsoft does offer a GitHub Action for Azure Code Signing, but that would involve a bit more surgery. (If we'd rather do things that way, however, it's certainly possible.) CMake will choose which code signing method to use based upon which environment variables are defined, as somebody might want to fork OpenTTD and sign it with a traditional certificate perhaps.

The actual code signing is performed via a PowerShell script. Microsoft takes a checksum of the binary, uploads it to Azure, where a signature is generated and returned (so the binaries themselves are not transferred). We don't get access to the actual certificate (which is valid for only 3 days before being regenerated automatically).

Limitations

If a user happens to be using an older version of Windows that hasn't been kept up-to-date, they may receive a certificate warning as the certification authority root certificate dates back to 2020 and has only been included in Windows for a couple of years. It's quite possible this would happen with other recent code signing certificates anyway, though.

The Azure client secret is valid for a maximum of 2 years, so will need to be regenerated and updated in the GitHub secrets store periodically.

Checklist for review

Some things are not automated, and forgotten often. This list is a reminder for the reviewers.

  • The bug fix is important enough to be backported? (label: 'backport requested')
  • This PR touches english.txt or translations? Check the guidelines
  • This PR affects the save game format? (label 'savegame upgrade')
  • This PR affects the GS/AI API? (label 'needs review: Script API')
    • ai_changelog.hpp, game_changelog.hpp need updating.
    • The compatibility wrappers (compat_*.nut) need updating.
  • This PR affects the NewGRF API? (label 'needs review: NewGRF')

@orudge
Copy link
Contributor Author

orudge commented Mar 13, 2024

Currently, the preview is free; it's not yet clear when this will become generally available or what pricing may be involved, but one would hope it'll be considerably cheaper than the alternatives.

As if by magic, MS have just sent an invitation to a call next week where they are announcing a Public Preview, plus pricing details and so on. I'll hopefully be able to attend and find out more then.

Copy link
Member

@TrueBrain TrueBrain left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking good! Some minor stuff to tidy things up a bit :)

Owh, and we should definitely wait for the pricing announcement, just so we know what we are getting ourselves into :)

.github/workflows/release-windows.yml Outdated Show resolved Hide resolved
.github/workflows/release-windows.yml Show resolved Hide resolved
cmake/InstallAndPackage.cmake Outdated Show resolved Hide resolved
os/windows/sign_azure.ps1 Show resolved Hide resolved
@TrueBrain TrueBrain changed the title Change: [CI] Use Azure Code Signing for Windows build Codechange: [CI] Use Azure Code Signing for Windows build Mar 13, 2024
@orudge orudge force-pushed the azure-code-signing branch 2 times, most recently from 901a11f to 42f64af Compare March 19, 2024 16:29
Copy link
Member

@TrueBrain TrueBrain left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking good! One minor thing :)

Comment on lines 23 to 24
"The required environment variables have not been set up. Please check the script source for details."
"Skipping signing."
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
"The required environment variables have not been set up. Please check the script source for details."
"Skipping signing."
"Codesigning variables not found; most likely running in a fork. Skipping signing."

@TrueBrain TrueBrain added the backport requested This PR should be backport to current release (RC / stable) label Mar 19, 2024
@orudge
Copy link
Contributor Author

orudge commented Mar 19, 2024

For the historical record, I attended a meeting with Microsoft today regarding the public preview and eventual production release of the Azure Code Signing service. This included information on pricing, and while I don't know that I'm at liberty to share that information at this time, I can confirm that it should be quite affordable for us (and certainly cheaper than an EV code signing certificate and so on).

@orudge orudge enabled auto-merge (rebase) March 19, 2024 22:42
@orudge orudge merged commit d4a6ee9 into OpenTTD:master Mar 19, 2024
15 checks passed
@orudge orudge deleted the azure-code-signing branch March 20, 2024 09:10
@rubidium42 rubidium42 mentioned this pull request Mar 23, 2024
@rubidium42 rubidium42 added backported This PR is backported to a current release (RC / stable) and removed backport requested This PR should be backport to current release (RC / stable) labels Mar 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backported This PR is backported to a current release (RC / stable)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants