Skip to content
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
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ VERSION=$(RELEASE_VERSION)
endif
endif

GO_LDFLAGS=-ldflags "-X github.com/Venafi/vcert/v5.versionString=$(VERSION) -X github.com/Venafi/vcert/v5.versionBuildTimeStamp=`date -u +%Y%m%d.%H%M%S` -s -w"
GO_LDFLAGS=-ldflags "-X github.com/Venafi/vcert/v5.versionString=$(VERSION) -X github.com/Venafi/vcert/v5.versionBuildTimeStamp=`date -u +%Y%m%d.%H%M%S` -X github.com/Venafi/vcert/v5/pkg/util.versionString=$(VERSION) -s -w"
version:
echo "$(VERSION)"

Expand Down
4 changes: 4 additions & 0 deletions cmd/vcert/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@ func buildConfigFake(_ *commandFlags) (*vcert.Config, error) {
return &vcert.Config{
ConnectorType: endpoint.ConnectorTypeFake,
Credentials: &endpoint.Authentication{},
UserAgent: vcert.GetUserAgentCLI(),
}, nil
}

Expand All @@ -145,6 +146,7 @@ func buildConfigTPP(commandName string, flags *commandFlags) (*vcert.Config, err
ConnectionTrust: "",
LogVerbose: false,
Client: nil,
UserAgent: vcert.GetUserAgentCLI(),
}

if commandName == commandGetCredName {
Expand All @@ -168,6 +170,7 @@ func buildConfigVaaS(flags *commandFlags) (*vcert.Config, error) {
ExternalJWT: flags.externalJWT,
TokenURL: flags.tokenURL,
},
UserAgent: vcert.GetUserAgentCLI(),
}, nil
}

Expand All @@ -188,5 +191,6 @@ func buildConfigFirefly(flags *commandFlags) (*vcert.Config, error) {
Audience: flags.audience,
},
},
UserAgent: vcert.GetUserAgentCLI(),
}, nil
}
2 changes: 1 addition & 1 deletion cmd/vcert/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ COPYRIGHT:
SUPPORT:
opensource@venafi.com
{{end}}
`, vcert.GetFormattedVersionString(), vcert.GetFormatedBuildTimeStamp())
`, vcert.GetFormattedVersionString(), vcert.GetFormattedBuildTimeStamp())

cli.CommandHelpTemplate = `NAME:
{{.HelpName}} - {{.Usage}}
Expand Down
1 change: 1 addition & 0 deletions config.go
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,7 @@ func LoadConfigFromFile(path, section string) (cfg Config, err error) {
cfg.ConnectorType = connectorType
cfg.Credentials = auth
cfg.BaseUrl = baseUrl
cfg.UserAgent = GetUserAgentCLI()

return
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/endpoint/endpoint.go
Original file line number Diff line number Diff line change
Expand Up @@ -367,7 +367,7 @@ func (p *Policy) ValidateCertificateRequest(request *certificate.Request) error
return nil
}

// SimpleValidateCertificateRequest functions just check Common Name and SANs mathching with policies
// SimpleValidateCertificateRequest functions just check Common Name and SANs matching with policies
func (p *Policy) SimpleValidateCertificateRequest(request certificate.Request) error {
csr := request.GetCSR()
const (
Expand Down
6 changes: 6 additions & 0 deletions pkg/playbook/app/vcertutil/helper.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import (

"go.uber.org/zap"

"github.com/Venafi/vcert/v5"
"github.com/Venafi/vcert/v5/pkg/certificate"
"github.com/Venafi/vcert/v5/pkg/playbook/app/domain"
"github.com/Venafi/vcert/v5/pkg/util"
Expand Down Expand Up @@ -239,3 +240,8 @@ func readFile(fileName string) ([]byte, error) {
}
return bytes, nil
}

func getUserAgent() *string {
userAgent := fmt.Sprintf("vcert-playbook/%s", vcert.GetFormattedVersionString()[1:])
return &userAgent
}
1 change: 1 addition & 0 deletions pkg/playbook/app/vcertutil/vcertutil.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ func buildClient(config domain.Config, zone string) (endpoint.Connector, error)
Zone: zone,
ConnectionTrust: loadTrustBundle(config.Connection.TrustBundlePath),
LogVerbose: false,
UserAgent: getUserAgent(),
}

// build Authentication object
Expand Down
18 changes: 17 additions & 1 deletion pkg/util/constants.go
Original file line number Diff line number Diff line change
@@ -1,9 +1,25 @@
package util

import (
"fmt"
)

const (
PathSeparator = "\\"
ApplicationServerTypeID = "784938d1-ef0d-11eb-9461-7bb533ba575b"
)

var (
// We load this variable from build command instead of reusing the vcert one to avoid circular dependencies
versionString string
// DefaultUserAgent is the default value of the UserAgent header in HTTP
// requests to Venafi API endpoints.
DefaultUserAgent = "vcert/v5"
DefaultUserAgent = fmt.Sprintf("vcert-sdk/%s", getVersionString()[1:])
)

func getVersionString() string {
if versionString == "" {
return "Unknown"
}
return versionString
}
2 changes: 1 addition & 1 deletion pkg/venafi/cloud/cloud.go
Original file line number Diff line number Diff line change
Expand Up @@ -668,7 +668,7 @@ type cloudZone struct {
templateAlias string
}

func (z cloudZone) String() string {
func (z *cloudZone) String() string {
return z.zone
}

Expand Down
11 changes: 9 additions & 2 deletions vcert.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,12 @@
* limitations under the License.
*/
/*
VCert is a Go library, SDK, and command line utility designed to simplify key generation and enrollment of machine identities (also known as SSL/TLS certificates and keys) that comply with enterprise security policy by using the Venafi Platform or Venafi Cloud.
Package vcert is a Go library, SDK, and command line utility designed to simplify key generation and enrollment of machine identities (also known as SSL/TLS certificates and keys) that comply with enterprise security policy by using the Venafi Platform or Venafi Cloud.
*/
package vcert

import "fmt"

var (
versionBuildTimeStamp string
versionString string
Expand All @@ -31,9 +33,14 @@ func GetFormattedVersionString() string {
return versionString
}

func GetFormatedBuildTimeStamp() string {
func GetFormattedBuildTimeStamp() string {
if versionBuildTimeStamp == "" {
versionBuildTimeStamp = "Unknown"
}
return versionBuildTimeStamp
}

func GetUserAgentCLI() *string {
userAgent := fmt.Sprintf("vcert-cli/%s", GetFormattedVersionString()[1:])
return &userAgent
}