Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 154
feat: use git config to read tsa server and include-certs#64
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base:main
Are you sure you want to change the base?
Uh oh!
There was an error while loading. Please reload this page.
Changes from all commits
File filter
Filter by extension
Conversations
Uh oh!
There was an error while loading. Please reload this page.
Jump to
Uh oh!
There was an error while loading. Please reload this page.
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -44,6 +44,32 @@ You can download prebuilt Windows binaries [here](https://github.com/github/smim | ||
| - You'll probably want to put `$GOPATH/bin` on your `$PATH`. | ||
| - Run `go get github.com/github/smimesign` | ||
| ## Standalone usage | ||
| ```sh | ||
| $ smimesign --help | ||
| Usage: smimesign [-abhsv] [--include-certs n] [--keyid-format {long}] [--list-keys] [--status-fd n] [-t url] [-u USER-ID] [--verify] [files] | ||
| -a, --armor create ascii armored output | ||
| -b, --detach-sign make a detached signature | ||
| -h, --help print this help message | ||
| --include-certs=n -3 is the same as -2, but ommits issuer | ||
| when cert has Authority Information | ||
| Access extension. -2 includes all certs | ||
| except root. -1 includes all certs. 0 | ||
| includes no certs. 1 includes leaf cert. | ||
| >1 includes n from the leaf. Default -2. | ||
| --keyid-format={long} select how to display key IDs. | ||
| --list-keys show keys | ||
| -s, --sign make a signature | ||
| --status-fd=n write special status strings to the file | ||
| descriptor n. | ||
| -t, --timestamp-authority=url URL of RFC3161 timestamp authority to | ||
| use for timestamping | ||
| -u, --local-user=USER-ID use USER-ID to sign | ||
| --verify verify a signature | ||
| -v, --version print the version number | ||
| ``` | ||
| ## Configuring Git | ||
| Git needs to be told to sign commits and tags using smimesign instead of GnuPG. This can be configured on a global or per-repository level. The Git configuration directives for changing signing tools was changed in version 2.19. | ||
| @@ -96,6 +122,15 @@ $ git config --get user.email | ||
| $ smimesign --list-keys | ||
| ``` | ||
| **Add smimesign options** | ||
| Currently only `tsa` and `include-certs` options are supported. | ||
| ```bash | ||
| $ git config --global gpg.x509.smimesign.timestamp-authority http://timestamp.digicert.com | ||
| $ git config --global gpg.x509.smimesign.include-certs -1 | ||
bufferoverflow marked this conversation as resolved.
Uh oh!There was an error while loading. Please reload this page. | ||
| ``` | ||
| ## Smart cards (PIV/CAC/Yubikey) | ||
| 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. | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -7,6 +7,7 @@ import ( | ||
| "io" | ||
| "os" | ||
| git "github.com/libgit2/git2go/v30" | ||
| "github.com/github/certstore" | ||
| "github.com/pborman/getopt/v2" | ||
| "github.com/pkg/errors" | ||
| @@ -72,6 +73,26 @@ func runCommand() error { | ||
| return nil | ||
| } | ||
| // read tsa and include-certs from gitconfig | ||
| path, err := os.Getwd() | ||
| if err == nil { | ||
Member There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is there a reason we want to "fail open" here and not return if an error is returned? Author There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. read tsa and include-cert should be optional, so just use the defaults if these are not defined within git config | ||
| repo, err := git.OpenRepository(path) | ||
| if err == nil { | ||
Member There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same question about failing open. The idiom used throughout is | ||
| config, err := repo.Config() | ||
| tsa, err := config.LookupString("gpg.x509.smimesign.timestamp-authority") | ||
Member There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What do we get from | ||
| if err == nil { | ||
| tsaOpt = &tsa | ||
| } | ||
| includeCerts32, err := config.LookupInt32("gpg.x509.smimesign.include-certs") | ||
| if err == nil { | ||
Member There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same question here..if no such setting is set..do we get | ||
| var includeCerts int = int(includeCerts32) | ||
| includeCertsOpt = &includeCerts | ||
| } | ||
| } | ||
| } | ||
| // Open certificate store | ||
| store, err := certstore.Open() | ||
| if err != nil { | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
❤️