Skip to content

Commit 2c7e910

Browse files
feat: use git config to read tsa server and include-certs
1 parent 7e96b8b commit 2c7e910

File tree

5 files changed

+35
-1
lines changed

5 files changed

+35
-1
lines changed

.travis.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@ go:
1010
git:
1111
depth: false
1212

13-
install: ''
13+
install:
14+
- brew install libgit2
1415

1516
script:
1617
- GIT_VERSION=$(git describe --tags)

README.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,15 @@ $ git config --get user.email
9696
$ smimesign --list-keys
9797
```
9898

99+
**Add smimesign options**
100+
101+
Currently only `tsa` and `include-certs` options are supported.
102+
103+
```bash
104+
$ git config --global gpg.x509.smimesign.tsa http://timestamp.digicert.com
105+
$ git config --global gpg.x509.smimesign.include-certs -1
106+
```
107+
99108
## Smart cards (PIV/CAC/Yubikey)
100109

101110
Many large organizations and government agencies distribute certificates and keys to end users via smart cards. These cards allow applications on the user's computer to use private keys for signing or encryption without giving them the ability to export those keys. The native certificate stores on both Windows and macOS can talk to smart cards, though special drivers or middleware may be required.

go.mod

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ go 1.12
55
require (
66
github.com/certifi/gocertifi v0.0.0-20180118203423-deb3ae2ef261
77
github.com/davecgh/go-spew v1.1.1
8+
github.com/libgit2/git2go/v29 v29.0.2
89
github.com/mastahyeti/certstore v0.0.5
910
github.com/mastahyeti/cms v0.0.6
1011
github.com/mastahyeti/fakeca v0.0.1

go.sum

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ github.com/certifi/gocertifi v0.0.0-20180118203423-deb3ae2ef261/go.mod h1:GJKEex
33
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
44
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
55
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
6+
github.com/libgit2/git2go/v29 v29.0.2 h1:tejTEV+B3n48nx027dDUFMLQPSvKo+E1Y6WUZVlJvRo=
7+
github.com/libgit2/git2go/v29 v29.0.2/go.mod h1:GnXk1stNspaGKX8uisx1aGefUwLxzc6Ad+PfdVpEKhQ=
68
github.com/mastahyeti/certstore v0.0.4 h1:lIS0StbHgmgUIpen7aayW+BGBFs7g141fOcjuobrFj8=
79
github.com/mastahyeti/certstore v0.0.4/go.mod h1:G29tHH2jDKK45cvISMzk8ZRf3KrhRS7ptoteyYzztsk=
810
github.com/mastahyeti/certstore v0.0.5 h1:8JV/YC8jN6SD+ocJi46PSdxXfPxwgilJJEA8HnG49ls=

main.go

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import (
77
"io"
88
"os"
99

10+
git "github.com/libgit2/git2go/v29"
1011
"github.com/mastahyeti/certstore"
1112
"github.com/pborman/getopt/v2"
1213
"github.com/pkg/errors"
@@ -72,6 +73,26 @@ func runCommand() error {
7273
return nil
7374
}
7475

76+
// read tsa and include-certs from gitconfig
77+
path, err := os.Getwd()
78+
if err == nil {
79+
repo, err := git.OpenRepository(path)
80+
if err == nil {
81+
config, err := repo.Config()
82+
83+
tsa, err := config.LookupString("gpg.x509.smimesign.tsa")
84+
if err == nil {
85+
tsaOpt = &tsa
86+
}
87+
88+
includeCerts32, err := config.LookupInt32("gpg.x509.smimesign.include-certs")
89+
if err == nil {
90+
var includeCerts int = int(includeCerts32)
91+
includeCertsOpt = &includeCerts
92+
}
93+
}
94+
}
95+
7596
// Open certificate store
7697
store, err := certstore.Open()
7798
if err != nil {

0 commit comments

Comments
 (0)