Skip to content

Embed binary releases signing key as a file instead of hardcoding a string #9247

Closed

Description

@gudvinr

Currently, signing key is hardcoded as text:

var SigningKey = []byte(`-----BEGIN EC PUBLIC KEY-----
MIGbMBAGByqGSM49AgEGBSuBBAAjA4GGAAQA1iRk+p+DsmolixxVKcpEVlMDPOeQ
1dWthURMqsjxoJuDAe5I98P/A0kXSdBI7avm5hXhX2opJ5TAyBZLHPpDTRoBg4WN
7jUpeAjtPoVVxvOh37qDeDVcjCgJbbDTPKbjxq/Ae3SHlQMRcoes7lVY1+YJ8dPk
2oPfjA6jtmo9aVbf/uo=
-----END EC PUBLIC KEY-----`)

Release Signing page states:

You can then sign binaries with the private key using stsigtool sign, verify them with the public key using stsigtool verify, and have Syncthing accept these signatures by replacing the compiled in public key. This may be useful in an enterprise setting, for example.

So, "in an enterprise setting" you'd either need to patch/replace signingkey.go on the fly or maintain separate copy of the repo and rebase signature changes on top of every release.

Solution

Since introduction of embed package in Go 1.16 embedding keyfile becomes as simple as this:

import _ "embed"

//go:embed pubkey.pem
var SigningKey []byte
$ cat pubkey.pem
-----BEGIN EC PUBLIC KEY----- 
MIGbMBAGByqGSM49AgEGBSuBBAAjA4GGAAQA1iRk+p+DsmolixxVKcpEVlMDPOeQ 
1dWthURMqsjxoJuDAe5I98P/A0kXSdBI7avm5hXhX2opJ5TAyBZLHPpDTRoBg4WN 
7jUpeAjtPoVVxvOh37qDeDVcjCgJbbDTPKbjxq/Ae3SHlQMRcoes7lVY1+YJ8dPk 
2oPfjA6jtmo9aVbf/uo= 
-----END EC PUBLIC KEY-----

This makes it possible to simply replace pubkey.pem during build without fiddling with go source files.

Activity

  1. added
    enhancement
    needs-triage
    on Nov 30, 2023
  2. added
    build
    and removed
    enhancement
    needs-triage
    on Dec 13, 2023
  3. added a commit that references this issue on Dec 18, 2023
    059a53f
  4. added a commit that references this issue on Dec 18, 2023
    91084b8
  5. added this to the v1.27.2 milestone on Dec 25, 2023
  6. added 2 commits that reference this issue on Jan 4, 2024
    db2c610
    cbead14
  7. added
    frozen-due-to-age
    on Apr 9, 2025
  8. locked and limited conversation to collaborators on Apr 9, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    buildfrozen-due-to-age

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions