Skip to content

Conversation

@fryshorts
Copy link
Contributor

@fryshorts fryshorts commented Apr 4, 2025

These patches add the option to cache the signatures generated by keys. We implemented this, because our internal processes are not ... optimal, and thus some binaries are getting signed repeatedly in CI/CD without changing.
Since we pay per signature, this will hopefully help us (and others in the same situation) to save some money.

I added the memcache option to individual keys instead of the key section or anywhere else because:

  • It was convenient
  • We only care for caching on one of our keys, while the others can do without

Since i was not sure if you would want to add the feature, i did not spend time on prometheus metrics. If you are interested in merging this, i can add those as well.

Leonhard Oelke added 2 commits April 4, 2025 19:08
Add a memcached option to keys. When enabled, it allows for caching of
signatures in case the same file gets signed multiple times.

Signed-off-by: Leonhard Oelke <[email protected]>
When caching for a key is enabled, this will add an additional property
to the audit message to show if the signature was fetched from cache.

Signed-off-by: Leonhard Oelke <[email protected]>
# Optional memcache servers for memoizing signing requests
#memcache:
# - 127.0.0.1:11211

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Should i mention that the cache should be cleared after changing the key configuration?

}

func (c *signatureCache) Sign(rand io.Reader, digest []byte, opts crypto.SignerOpts) ([]byte, error) {
cacheKey := fmt.Sprintf("sig-%s-%x", c.keyConf.Name(), digest)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm making the following assumptions here:

  • If the key configuration changes for the named key, the user should clear the cache
  • Digests from different Hashing-Algorithms will not collide

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.

1 participant