Skip to content

Commit

Permalink
Fix absolute file path for gRPC TLS certs
Browse files Browse the repository at this point in the history
  • Loading branch information
sarunask committed Feb 23, 2022
1 parent 993d6ec commit 6a22144
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions executors/grpc/grpc.go
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,10 @@ func (Executor) Run(ctx context.Context, step venom.TestStep) (interface{}, erro

// connect to a TLS server
if e.TLSRootCA != "" {
TLSRootCAFilepath := filepath.Join(workdir, e.TLSRootCA)
TLSRootCAFilepath := e.TLSRootCA
if !filepath.IsAbs(e.TLSRootCA) {
TLSRootCAFilepath = filepath.Join(workdir, e.TLSRootCA)
}
var TLSRootCA []byte
if _, err := os.Stat(TLSRootCAFilepath); err == nil {
TLSRootCA, err = os.ReadFile(TLSRootCAFilepath)
Expand All @@ -166,7 +169,10 @@ func (Executor) Run(ctx context.Context, step venom.TestStep) (interface{}, erro
// connect to a mutual TLS server
var TLSClientCert, TLSClientKey []byte
if e.TLSClientCert != "" {
TLSClientCertFilepath := filepath.Join(workdir, e.TLSClientCert)
TLSClientCertFilepath := e.TLSClientCert
if !filepath.IsAbs(e.TLSClientCert) {
TLSClientCertFilepath = filepath.Join(workdir, e.TLSClientCert)
}
if _, err := os.Stat(TLSClientCertFilepath); err == nil {
TLSClientCert, err = os.ReadFile(TLSClientCertFilepath)
if err != nil {
Expand All @@ -178,7 +184,10 @@ func (Executor) Run(ctx context.Context, step venom.TestStep) (interface{}, erro
}

if e.TLSClientKey != "" {
TLSClientKeyFilepath := filepath.Join(workdir, e.TLSClientKey)
TLSClientKeyFilepath := e.TLSClientKey
if !filepath.IsAbs(e.TLSClientKey) {
TLSClientKeyFilepath = filepath.Join(workdir, e.TLSClientKey)
}
if _, err := os.Stat(TLSClientKeyFilepath); err == nil {
TLSClientKey, err = os.ReadFile(TLSClientKeyFilepath)
if err != nil {
Expand Down

0 comments on commit 6a22144

Please sign in to comment.