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

keep the drive letter prefix in the path for windows #7094

Merged
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
27 changes: 20 additions & 7 deletions cmd/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import (
"github.com/spf13/cobra"

"github.com/open-policy-agent/opa/cmd/internal/env"
fileurl "github.com/open-policy-agent/opa/internal/file/url"
"github.com/open-policy-agent/opa/runtime"
"github.com/open-policy-agent/opa/server"
"github.com/open-policy-agent/opa/util"
Expand Down Expand Up @@ -291,18 +292,31 @@ func initRuntime(ctx context.Context, params runCmdParams, args []string, addrSe
"1.3": tls.VersionTLS13,
}

cert, err := loadCertificate(params.tlsCertFile, params.tlsPrivateKeyFile)
tlsCertFilePath, err := fileurl.Clean(params.tlsCertFile)
if err != nil {
return nil, fmt.Errorf("invalid certificate file path: %w", err)
}
tlsPrivateKeyFilePath, err := fileurl.Clean(params.tlsPrivateKeyFile)
if err != nil {
return nil, fmt.Errorf("invalid certificate private key file path: %w", err)
}
tlsCACertFilePath, err := fileurl.Clean(params.tlsCACertFile)
if err != nil {
return nil, fmt.Errorf("invalid CA certificate file path: %w", err)
}

cert, err := loadCertificate(tlsCertFilePath, tlsPrivateKeyFilePath)
if err != nil {
return nil, err
}

params.rt.CertificateFile = params.tlsCertFile
params.rt.CertificateKeyFile = params.tlsPrivateKeyFile
params.rt.CertificateFile = tlsCertFilePath
params.rt.CertificateKeyFile = tlsPrivateKeyFilePath
params.rt.CertificateRefresh = params.tlsCertRefresh
params.rt.CertPoolFile = params.tlsCACertFile
params.rt.CertPoolFile = tlsCACertFilePath

if params.tlsCACertFile != "" {
pool, err := loadCertPool(params.tlsCACertFile)
if tlsCACertFilePath != "" {
pool, err := loadCertPool(tlsCACertFilePath)
if err != nil {
return nil, err
}
Expand Down Expand Up @@ -422,7 +436,6 @@ func historyPath() string {
}

func loadCertificate(tlsCertFile, tlsPrivateKeyFile string) (*tls.Certificate, error) {

if tlsCertFile != "" && tlsPrivateKeyFile != "" {
cert, err := tls.LoadX509KeyPair(tlsCertFile, tlsPrivateKeyFile)
if err != nil {
Expand Down