Skip to content
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

Adds capability to define EKUs to be included in CSRs #527

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,9 @@ build: get
env GOOS=linux GOARCH=arm64 go build $(GO_LDFLAGS) -o bin/linux/vcert_arm ./cmd/vcert
env GOOS=linux GOARCH=amd64 go build $(GO_LDFLAGS) -o bin/linux/vcert ./cmd/vcert
env GOOS=linux GOARCH=386 go build $(GO_LDFLAGS) -o bin/linux/vcert86 ./cmd/vcert
env GOOS=linux GOARCH=arm GOARM=5 go build $(GO_LDFLAGS) -o bin/linux/vcert_arm32v5 ./cmd/vcert
env GOOS=linux GOARCH=arm GOARM=6 go build $(GO_LDFLAGS) -o bin/linux/vcert_arm32v6 ./cmd/vcert
env GOOS=linux GOARCH=arm GOARM=7 go build $(GO_LDFLAGS) -o bin/linux/vcert_arm32v7 ./cmd/vcert
env GOOS=darwin GOARCH=amd64 go build $(GO_LDFLAGS) -o bin/darwin/vcert ./cmd/vcert
env GOOS=darwin GOARCH=arm64 go build $(GO_LDFLAGS) -o bin/darwin/vcert_arm ./cmd/vcert
env GOOS=windows GOARCH=amd64 go build $(GO_LDFLAGS) -o bin/windows/vcert.exe ./cmd/vcert
Expand Down
1 change: 1 addition & 0 deletions cmd/vcert/args.go
Original file line number Diff line number Diff line change
Expand Up @@ -156,4 +156,5 @@ type commandFlags struct {
provisionOutputFile string
provisionPickupID string
provisionFormat string
extKeyUsage certificate.ExtKeyUsageSlice
}
4 changes: 4 additions & 0 deletions cmd/vcert/cmdHelper.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,10 @@ func runBeforeCommand(c *cli.Context) error {
uri, _ := url.Parse(stringURI)
flags.uriSans = append(flags.uriSans, uri)
}
for _, stringExtKeyUsage := range c.StringSlice("eku") {
eku, _ := certificate.ParseExtKeyUsage(stringExtKeyUsage)
flags.extKeyUsage.Add(eku)
}

if flags.platformString != "" {
flags.platform = venafi.GetPlatformType(flags.platformString)
Expand Down
10 changes: 10 additions & 0 deletions cmd/vcert/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,13 @@ var (
Hidden: true,
}

flagExtKeyUsage = &cli.StringSliceFlag{
Name: "eku",
Usage: "Use to specify an Extended Key Usage type to be included in the generated CSR. Common options include ServerAuth & ClientAuth. " +
"This option can be repeated to specify more than one value like this: --eku ServerAuth --eku ClientAuth etc. ",
Hidden: true,
}

flagFormat = &cli.StringFlag{
Name: "format",
Usage: "Use to specify the output format. Options include: pem | json | pkcs12 | jks | legacy-pem | legacy-pkcs12." +
Expand Down Expand Up @@ -802,6 +809,7 @@ var (
sansFlags,
flagCSRFile,
keyFlags,
flagExtKeyUsage,
flagNoPrompt,
flagVerbose,
flagCSRFormat,
Expand Down Expand Up @@ -839,6 +847,7 @@ var (
flagOmitSans,
flagValidDays,
flagValidPeriod,
flagExtKeyUsage,
)),
)

Expand Down Expand Up @@ -896,6 +905,7 @@ var (
sortableCredentialsFlags,
flagPickupIDFile,
flagOmitSans,
flagExtKeyUsage,
)),
)

Expand Down
3 changes: 3 additions & 0 deletions cmd/vcert/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,9 @@ func fillCertificateRequest(req *certificate.Request, cf *commandFlags) *certifi
req.KeyCurve = cf.keyCurve
}
req.CsrOrigin = certificate.LocalGeneratedCSR
if len(cf.extKeyUsage) > 0 {
req.ExtKeyUsages = cf.extKeyUsage
}
}

if cf.validDays != "" {
Expand Down
Loading