Add support for SSH-signed commits - #171
Conversation
nlewo
left a comment
There was a problem hiding this comment.
Thank you for this contribution which has been already asked by several users!
463ce8c to
2740669
Compare
- Refuse ssh-rsa and ssh-dss signature algorithms in SSH signatures, matching OpenSSH's sshsig behavior, since x/crypto otherwise accepts SHA-1 based signatures for RSA keys. - Parse the allowed signers file once in New() and store the parsed signers instead of re-parsing on every update. - Report both GPG and SSH verification errors when both trust sources are configured, instead of only the last one.
|
I had the branch reviewed by Claude (Fable 5), which caught a few more things, fixed in 31b3f47:
|
|
Fixed the lint in ded5429. Happy to address any other concerns! |
|
To be honest, I'm not feeling really confident by merging this PR since it's hard to be sure we will not miss any attack screnario... I noticed the go-git project is implementing the support of SSH signed commit in go-git/go-git#1869 and go-git/x#13. I would be really nice to use this codebase instead of having to maintain our own... I also noticed flux implemented a SSH signed commit support in fluxcd/pkg#1141. I still need to take some time reviewing this PR and should be able to in the next couple of days. |
|
So, I didn't see any issue in this PR. @basnijholt Thank you for your contribution! |
|
Deployed on my infra and no regression observed. |
|
@nlewo thanks for merging 🎉 😄 |
This adds support for verifying commits signed with SSH keys, alongside the existing GPG support.
I use SSH keys to sign my commits, and GitHub has supported SSH commit verification since August 23, 2022. This makes SSH signing a practical alternative to GPG for people who already manage SSH keys as part of their normal Git workflow.
The main new option is:
The file uses OpenSSH’s allowed signers format, so a simple entry looks like:
A commit is accepted if it verifies against either a configured GPG public key or a configured SSH allowed signer.
I kept the SSH parser intentionally conservative. It supports plain public-key entries and optional
namespaces="git"restrictions, but rejects unsupported allowed-signers features instead of guessing. That includes unsupported options, ambiguous namespace patterns, SSH cert keys, and malformed entries.I also updated the docs and regenerated the module options.
Tested with:
go build -v ./... go test -race -v ./... nix flake checkI also added live SSH-signing tests that generate an SSH key, create a real
git commit -Scommit, and verify it through comin’s update path.