Skip to content

Commit

Permalink
Merge pull request #51 from github/wire-up-read-signature-in-signning
Browse files Browse the repository at this point in the history
Wire up reading file for signing command
  • Loading branch information
cryptoque authored Apr 3, 2019
2 parents 9fcafad + 916eb4b commit 10cd0a6
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion command_sign.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"encoding/pem"
"fmt"
"io"
"os"
"strings"

"github.com/mastahyeti/certstore"
Expand Down Expand Up @@ -37,8 +38,18 @@ func commandSign() error {
return errors.Wrap(err, "failed to get idenity signer")
}

var f io.ReadCloser
if len(fileArgs) == 1 {
if f, err = os.Open(fileArgs[0]); err != nil {
return errors.Wrapf(err, "failed to open message file (%s)", fileArgs[0])
}
defer f.Close()
} else {
f = stdin
}

dataBuf := new(bytes.Buffer)
if _, err = io.Copy(dataBuf, stdin); err != nil {
if _, err = io.Copy(dataBuf, f); err != nil {
return errors.Wrap(err, "failed to read message from stdin")
}

Expand Down

0 comments on commit 10cd0a6

Please sign in to comment.