diff options
author | Niall Sheridan <nsheridan@gmail.com> | 2016-08-15 10:52:25 +0100 |
---|---|---|
committer | Niall Sheridan <nsheridan@gmail.com> | 2016-08-15 10:52:25 +0100 |
commit | 870e7b848f3c3a8e2846bc377b575466c66bd0ca (patch) | |
tree | a74031fe47150ae4bd62936e2e10eca031982beb | |
parent | a869e39e90effc0720d8940d5aba6603953eee3d (diff) |
Ensure the /sign url is valid before use
-rw-r--r-- | cmd/cashier/main.go | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/cmd/cashier/main.go b/cmd/cashier/main.go index 3a34108..a9c509f 100644 --- a/cmd/cashier/main.go +++ b/cmd/cashier/main.go @@ -9,6 +9,7 @@ import ( "log" "net" "net/http" + "net/url" "os" "os/user" "path" @@ -49,7 +50,12 @@ func send(s []byte, token, ca string, ValidateTLSCertificate bool) (*lib.SignRes TLSClientConfig: &tls.Config{InsecureSkipVerify: !ValidateTLSCertificate}, } client := &http.Client{Transport: transport} - req, err := http.NewRequest("POST", ca+"/sign", bytes.NewReader(s)) + u, err := url.Parse(ca) + if err != nil { + return nil, err + } + u.Path = path.Join(u.Path, "/sign") + req, err := http.NewRequest("POST", u.String(), bytes.NewReader(s)) if err != nil { return nil, err } |