Skip to content

feat: sign OTP build index files alongside builds.txt#264

Open
mvanhorn wants to merge 1 commit into
hexpm:mainfrom
mvanhorn:feat/237-sign-builds-txt
Open

feat: sign OTP build index files alongside builds.txt#264
mvanhorn wants to merge 1 commit into
hexpm:mainfrom
mvanhorn:feat/237-sign-builds-txt

Conversation

@mvanhorn

Copy link
Copy Markdown

Summary

Adds optional SHA-512 signing of OTP build index files. When BOB_BUILDS_SIGN_KEY is set to a PEM private key path, generate_builds_txt/2 uploads a base64-encoded builds.txt.signed sibling to S3 alongside the existing builds.txt, using identical cache-control and surrogate-key metadata. Fastly purge keys are extended to cover both files atomically. When the env var is absent the behavior is unchanged.

Why this matters

erlef/setup-beam downloads OTP builds from builds.hex.pm and currently has no way to verify the authenticity of the build index (see #237). Signing with a server-held private key lets consumers verify the index using the corresponding public key, adding a supply-chain integrity layer without changing any existing upload paths or requiring consumer changes to the download flow.

Changes

  • config/runtime.exs - reads BOB_BUILDS_SIGN_KEY (optional, nil when absent)
  • lib/bob/store.ex - adds sign_content/2: shells to openssl dgst -sha512 -sign and returns a base64-encoded signature, or nil when no key is configured
  • lib/bob/artifacts.ex - generate_builds_txt/2 signs content and uploads builds.txt.signed when a key is present; surrogate_keys/2 and purge_keys/3 include the .signed path so Fastly invalidations are atomic
  • test/bob/store_test.exs - tests for nil key passthrough, base64 output, and openssl round-trip verification
  • test/bob/artifacts_test.exs - tests for no-signed-upload without key, and signed upload with key stubbed in FakeHttpClient

Fixes #237

Adds optional SHA-512 signing of builds.txt via BOB_BUILDS_SIGN_KEY (path to
a PEM private key). When set, generate_builds_txt/2 uploads a base64-encoded
signature as a builds.txt.signed sibling with identical cache-control and
surrogate-key metadata; Fastly purge keys cover both files atomically.

Fixes hexpm#237
Comment thread lib/bob/store.ex
try do
File.write!(tmp, content)

case System.cmd("openssl", ["dgst", "-sha512", "-sign", pem_path, tmp],

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Could we use :public_key.sign/3 instead?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Sign Build Index Files

2 participants