From 9656e678acec29dca9378eba4b95857b41892f36 Mon Sep 17 00:00:00 2001 From: Ben Toews Date: Tue, 7 May 2019 10:11:51 -0600 Subject: [PATCH] output signature info to stderr Otherwise, `git --show-log` doesn't show any information about the signature and the user has no way of knowing that a commit was actually signed. --- command_verify.go | 21 +++++++++++++++++++-- status.go | 4 ++-- 2 files changed, 21 insertions(+), 4 deletions(-) diff --git a/command_verify.go b/command_verify.go index 11b12a4..5025a31 100644 --- a/command_verify.go +++ b/command_verify.go @@ -4,6 +4,7 @@ import ( "bytes" "crypto/x509" "encoding/pem" + "fmt" "io" "os" @@ -63,17 +64,25 @@ func verifyAttached() error { if len(chains) > 0 { emitBadSig(chains) } else { - // TODO: We're ommitting a bunch of arguments here. + // TODO: We're omitting a bunch of arguments here. sErrSig.emit() } return errors.Wrap(err, "failed to verify signature") } + var ( + cert = chains[0][0][0] + fpr = certHexFingerprint(cert) + subj = cert.Subject.String() + ) + + fmt.Fprintf(stderr, "smimesign: Signature made using certificate ID 0x%s\n", fpr) emitGoodSig(chains) // TODO: Maybe split up signature checking and certificate checking so we can // output something more meaningful. + fmt.Fprintf(stderr, "smimesign: Good signature from \"%s\"\n", subj) emitTrustFully() return nil @@ -131,17 +140,25 @@ func verifyDetached() error { if len(chains) > 0 { emitBadSig(chains) } else { - // TODO: We're ommitting a bunch of arguments here. + // TODO: We're omitting a bunch of arguments here. sErrSig.emit() } return errors.Wrap(err, "failed to verify signature") } + var ( + cert = chains[0][0][0] + fpr = certHexFingerprint(cert) + subj = cert.Subject.String() + ) + + fmt.Fprintf(stderr, "smimesign: Signature made using certificate ID 0x%s\n", fpr) emitGoodSig(chains) // TODO: Maybe split up signature checking and certificate checking so we can // output something more meaningful. + fmt.Fprintf(stderr, "smimesign: Good signature from \"%s\"\n", subj) emitTrustFully() return nil diff --git a/status.go b/status.go index 2b68638..9f789fd 100644 --- a/status.go +++ b/status.go @@ -206,7 +206,7 @@ func emitSigCreated(cert *x509.Certificate, isDetached bool) { func emitGoodSig(chains [][][]*x509.Certificate) { cert := chains[0][0][0] - subj := cert.Subject.ToRDNSequence().String() + subj := cert.Subject.String() fpr := certHexFingerprint(cert) sGoodSig.emitf("%s %s", fpr, subj) @@ -214,7 +214,7 @@ func emitGoodSig(chains [][][]*x509.Certificate) { func emitBadSig(chains [][][]*x509.Certificate) { cert := chains[0][0][0] - subj := cert.Subject.ToRDNSequence().String + subj := cert.Subject.String fpr := certHexFingerprint(cert) sBadSig.emitf("%s %s", fpr, subj)