Skip to content

Commit f3a4117

Browse files
author
Ricky White
authored
Update verification output for consistent UX. (#28)
Matches the output of `ssh-keygen`, the default signing program of git.
1 parent f90baaf commit f3a4117

File tree

1 file changed

+12
-5
lines changed

1 file changed

+12
-5
lines changed

cmd/ssh-sign/main.go

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ func main() {
2424
flag.StringVar(&namespace, "n", "", "Namespace")
2525
flag.StringVar(&inputFile, "f", "", "SSH Key UID or allowed_signers file")
2626
flag.StringVar(&signatureFile, "s", "", "Signature file for verification")
27-
flag.StringVar(&timestamp, "Overify-time", "", "TODO")
27+
flag.StringVar(&timestamp, "Overify-time", "", "Timestamp for verification of SSH Key. Not implemented.")
2828
flag.StringVar(&principal, "I", "", "Principal to verify")
2929
flag.Parse()
3030

@@ -192,9 +192,13 @@ func main() {
192192
fmt.Println(err)
193193
os.Exit(1)
194194
}
195-
196195
keyType := strings.ToUpper(strings.Split(key.Type(), "-")[1])
197-
fmt.Printf("Signature \"%s\" for \"%s\" with %s key %s is good.\n", namespace, principalEmail, keyType, ssh.FingerprintSHA256(key))
196+
197+
// Output the result to stdout, which will be used by git to determine
198+
// if the commit is valid. This output mirrors the output of the
199+
// default ssh git signing method (ssh-keygen). This is done to ensure
200+
// compatibility with git.
201+
fmt.Printf("Good \"%s\" signature for %s with %s key %s\n", namespace, principalEmail, keyType, ssh.FingerprintSHA256(key))
198202
os.Exit(0)
199203

200204
} else if action == "check-novalidate" {
@@ -207,9 +211,12 @@ func main() {
207211
fmt.Println(err)
208212
os.Exit(1)
209213
}
210-
211214
keyType := strings.ToUpper(strings.Split(sig.PublicKey.Type(), "-")[1])
212-
fmt.Printf("Signature \"%s\" with %s key %s is good.\n", namespace, keyType, ssh.FingerprintSHA256(sig.PublicKey))
215+
216+
// As above, this output mirrors the output of the default ssh git
217+
// signing method (ssh-keygen). This is done to ensure compatibility
218+
// with git.
219+
fmt.Printf("Good \"%s\" signature with %s key %s\n", namespace, keyType, ssh.FingerprintSHA256(sig.PublicKey))
213220
fmt.Println("No matching principal")
214221
os.Exit(0)
215222

0 commit comments

Comments
 (0)