Skip to content

Commit

Permalink
Merge pull request #20 from newcontext-oss/feature/cert-origin
Browse files Browse the repository at this point in the history
  • Loading branch information
nukdcbear authored Nov 19, 2020
2 parents 52fdae8 + acffa98 commit f591183
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 1 deletion.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ go 1.12

require (
code.cloudfoundry.org/credhub-cli v0.0.0-20191230184144-6e537b521d9d
github.com/Venafi/vcert v0.0.0-20200110160249-46ed6e7db59c
github.com/Venafi/vcert v0.0.0-20200421144231-dd32326727e2
github.com/kr/pretty v0.1.0 // indirect
github.com/stretchr/testify v1.4.0
golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550 // indirect
Expand Down
7 changes: 7 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
code.cloudfoundry.org/credhub-cli v0.0.0-20191230184144-6e537b521d9d h1:dVWZLkpuKr9CGe9AZ7/XpZoMd9Xn6kGCp5GPxS4dRhs=
code.cloudfoundry.org/credhub-cli v0.0.0-20191230184144-6e537b521d9d/go.mod h1:502BrJv21CY4FT748a8/iLboZ7lRPp6EXn5NmJBQZiM=
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
github.com/Venafi/vcert v0.0.0-20200110160249-46ed6e7db59c h1:ZhaaMuk7Smqq8+g0v3WChQU9WNq3mWWIBbR5VUVqETg=
github.com/Venafi/vcert v0.0.0-20200110160249-46ed6e7db59c/go.mod h1:5T4bFPhcgGXbdz8nVVRuE2gXSRDlZVL+9T5CwZZ3Yk4=
github.com/Venafi/vcert v0.0.0-20200421144231-dd32326727e2 h1:yb11bjHPrOQ6fvpX+NNDMD6pI89HTBOz9UAF+ejdnSI=
github.com/Venafi/vcert v0.0.0-20200421144231-dd32326727e2/go.mod h1:9EegQjmRoMqVT/ydgd54mJj5rTd7ym0qMgEfhnPsce0=
github.com/armon/go-socks5 v0.0.0-20160902184237-e75332964ef5/go.mod h1:wHh0iHkYZB8zMSxRWpUBQtwG5a7fFgvEO+odwuTv2gs=
github.com/bmatcuk/doublestar v1.1.1/go.mod h1:UD6OnuiIn0yFxxA2le/rnRU1G4RaI4UvFv1sNto9p6w=
github.com/charlievieth/fs v0.0.0-20170613215519-7dc373669fa1/go.mod h1:sAoA1zHCH4FJPE2gne5iBiiVG66U7Nyp6JqlOo+FEyg=
Expand All @@ -12,6 +15,7 @@ github.com/cloudfoundry/go-socks5 v0.0.0-20180221174514-54f73bdb8a8e/go.mod h1:P
github.com/cloudfoundry/socks5-proxy v0.2.0 h1:ZRXcJxUqOyKmah+ytXh52K7m7S7SyuBacDUnd2g0ihU=
github.com/cloudfoundry/socks5-proxy v0.2.0/go.mod h1:0a+Ghg38uB86Dx+de84dFSkILTnBHzCpFMRnjHgSzi4=
github.com/cppforlife/go-patch v0.1.0/go.mod h1:67a7aIi94FHDZdoeGSJRRFDp66l9MhaAG1yGxpUoFD8=
github.com/cpuguy83/go-md2man/v2 v2.0.0-20190314233015-f79a8a8ca69d/go.mod h1:maD7wRr/U5Z6m/iR4s+kqSMx2CaBsrgA7czyZG/E6dU=
github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/fatih/color v1.6.0/go.mod h1:Zm6kSWBoL9eyXnKyktHP6abPY2pDugNf5KwzbycvMj4=
Expand All @@ -38,13 +42,16 @@ github.com/onsi/gomega v1.3.0 h1:yPHEatyQC4jN3vdfvqJXG7O9vfC6LhaAV1NEdYpP+h0=
github.com/onsi/gomega v1.3.0/go.mod h1:C1qb7wdrVGGVU+Z6iS04AVkA3Q65CEZX59MT0QO5uiA=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/russross/blackfriday/v2 v2.0.1/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
github.com/shurcooL/sanitized_anchor_name v1.0.0/go.mod h1:1NzhyTcUVG4SuEtjjoZeVRXNmyL/1OwPU0+IJeTBvfc=
github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d h1:zE9ykElWQ6/NYmHa3jpm/yHnI4xSofP+UP6SpjHcSeM=
github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d/go.mod h1:OnSkiWE9lh6wB0YB77sQom3nweQdgAjqCqsofrRNTgc=
github.com/smartystreets/goconvey v0.0.0-20190330032615-68dc04aab96a h1:pa8hGb/2YqsZKovtsgrwcDH1RZhVbTKCjLp47XpqCDs=
github.com/smartystreets/goconvey v0.0.0-20190330032615-68dc04aab96a/go.mod h1:syvi0/a8iFYH4r/RixwvyeAJjdLS9QV7WQ/tjFTllLA=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/testify v1.4.0 h1:2E4SXV/wtOkTonXsotYi4li6zVWxYlZuYNCXe9XRJyk=
github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4=
github.com/urfave/cli/v2 v2.1.1/go.mod h1:SE9GqnLQmjVa0iPEY0f1w3ygNIYcIJ0OKPMoW2caLfQ=
golang.org/x/crypto v0.0.0-20180319061731-c3a3ad6d03f7 h1:ryKu9k3oWWgQUTahNaa+lDY2fruNO/7fqQVKQfl0Vmc=
golang.org/x/crypto v0.0.0-20180319061731-c3a3ad6d03f7/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
Expand Down
8 changes: 8 additions & 0 deletions vcclient/generate.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ type CertArgs struct {
SANDNS []string
KeyCurve certificate.EllipticCurve
OrganizationalUnit []string
Origin string
Country string
State string
Locality string
Expand Down Expand Up @@ -104,5 +105,12 @@ func buildGenerateRequest(v *CertArgs) (*certificate.Request, error) {
r.KeyPassword = v.KeyPassword
}
r.Subject = subject

r.CustomFields = append(r.CustomFields, certificate.CustomField{
Type: certificate.CustomFieldOrigin,
Name: "Origin",
Value: origin,
})

return r, nil
}
8 changes: 8 additions & 0 deletions vcclient/vcert.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import (
"github.com/newcontext-oss/credhub-venafi/output"
)

var origin = "NewContext Credhub-Venafi"
var CreatedAccessToken = false

// IVcertProxy defines the interface for proxies that manage requests to vcert
Expand Down Expand Up @@ -62,6 +63,13 @@ func (v *VcertProxy) PutCertificate(certName string, cert string, privateKey str
PrivateKeyData: privateKey,
// Password: "newPassw0rd!",
Reconcile: false,
CustomFields: []certificate.CustomField{
{
Type: certificate.CustomFieldOrigin,
Name: "Origin",
Value: origin,
},
},
}

importResp, err := v.Client.ImportCertificate(importReq)
Expand Down

0 comments on commit f591183

Please sign in to comment.