diff --git a/address.go b/address.go index 6c1ce4e..c7fec0a 100644 --- a/address.go +++ b/address.go @@ -1,3 +1,4 @@ +//go:build !windows // +build !windows /* @@ -33,11 +34,21 @@ func parseAddr(addr string) (*url.URL, error) { // As of go 1.12, url.Parse returns an error when given URLs that contain control characters. // https://golang.org/doc/go1.12#net/url if strings.HasPrefix(addr, "pem:") || strings.HasPrefix(addr, "-----BEGIN") { - url := &url.URL{ + ret := &url.URL{ Scheme: "pem", Opaque: strings.TrimPrefix(addr, "pem:"), } - return url, nil + return ret, nil } - return url.Parse(addr) + urlParts, err := url.Parse(addr) + + if err != nil { + return nil, err + } + + if urlParts.Scheme == "" { + urlParts.Scheme = StorageFile + } + + return urlParts, nil } diff --git a/identity.go b/identity.go index ae57b24..d8433a7 100644 --- a/identity.go +++ b/identity.go @@ -28,6 +28,7 @@ import ( "github.com/pkg/errors" "github.com/sirupsen/logrus" "os" + "path/filepath" "strings" "sync" "sync/atomic" @@ -185,28 +186,28 @@ func (id *ID) Reload() error { func (id *ID) getFiles() []string { var files []string if path, ok := IsFile(id.Config.Cert); ok { - files = append(files, path) + files = append(files, filepath.Clean(path)) } if path, ok := IsFile(id.Config.ServerCert); ok { - files = append(files, path) + files = append(files, filepath.Clean(path)) } if path, ok := IsFile(id.Config.Key); ok { - files = append(files, path) + files = append(files, filepath.Clean(path)) } if path, ok := IsFile(id.Config.ServerKey); ok { - files = append(files, path) + files = append(files, filepath.Clean(path)) } for _, altServerCert := range id.Config.AltServerCerts { if path, ok := IsFile(altServerCert.ServerKey); ok { - files = append(files, path) + files = append(files, filepath.Clean(path)) } if path, ok := IsFile(altServerCert.ServerCert); ok { - files = append(files, path) + files = append(files, filepath.Clean(path)) } }