Skip to content

Commit

Permalink
Merge pull request #56 from github/verify-output
Browse files Browse the repository at this point in the history
Output for verify command
  • Loading branch information
mastahyeti authored May 7, 2019
2 parents a1fe9f4 + 9656e67 commit 7e96b8b
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 4 deletions.
21 changes: 19 additions & 2 deletions command_verify.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"bytes"
"crypto/x509"
"encoding/pem"
"fmt"
"io"
"os"

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions status.go
Original file line number Diff line number Diff line change
Expand Up @@ -206,15 +206,15 @@ 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)
}

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)
Expand Down

0 comments on commit 7e96b8b

Please sign in to comment.