From aa1a297de932360c2247971efdc7bffff7027e7f Mon Sep 17 00:00:00 2001 From: poddm <8801231+poddm@users.noreply.github.com> Date: Wed, 8 Mar 2023 14:20:07 -0800 Subject: [PATCH 1/2] decode asterisk --- cloudstack/cloudstack.go | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/cloudstack/cloudstack.go b/cloudstack/cloudstack.go index 79633b19..ee1a4786 100644 --- a/cloudstack/cloudstack.go +++ b/cloudstack/cloudstack.go @@ -468,13 +468,17 @@ func (cs *CloudStackClient) newRawRequest(api string, post bool, params url.Valu // * Serialize parameters, URL encoding only values and sort them by key, done by encodeValues // * Convert the entire argument string to lowercase // * Replace all instances of '+' to '%20' + // * Replace encoded asterisk (*) back to literal. CloudStack’s internal encoder does not encode them; this results in an authentication failure for your API call. + // http://docs.cloudstack.apache.org/projects/archived-cloudstack-getting-started/en/latest/dev.html) // * Calculate HMAC SHA1 of argument string with CloudStack secret // * URL encode the string and convert to base64 s := encodeValues(params) - s2 := strings.ToLower(s) - s3 := strings.Replace(s2, "+", "%20", -1) + s = strings.ToLower(s) + s = strings.Replace(s, "+", "%20", -1) + s = strings.Replace(s, "%2a", "*", -1) + mac := hmac.New(sha1.New, []byte(cs.secret)) - mac.Write([]byte(s3)) + mac.Write([]byte(s)) signature := base64.StdEncoding.EncodeToString(mac.Sum(nil)) var err error From 792e347dd3ce1ceec99f92e798f4dd28f13d3c15 Mon Sep 17 00:00:00 2001 From: poddm <8801231+poddm@users.noreply.github.com> Date: Wed, 8 Mar 2023 14:23:59 -0800 Subject: [PATCH 2/2] decode asterisk --- cloudstack/cloudstack.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/cloudstack/cloudstack.go b/cloudstack/cloudstack.go index ee1a4786..c7c9eb6e 100644 --- a/cloudstack/cloudstack.go +++ b/cloudstack/cloudstack.go @@ -468,8 +468,9 @@ func (cs *CloudStackClient) newRawRequest(api string, post bool, params url.Valu // * Serialize parameters, URL encoding only values and sort them by key, done by encodeValues // * Convert the entire argument string to lowercase // * Replace all instances of '+' to '%20' - // * Replace encoded asterisk (*) back to literal. CloudStack’s internal encoder does not encode them; this results in an authentication failure for your API call. - // http://docs.cloudstack.apache.org/projects/archived-cloudstack-getting-started/en/latest/dev.html) + // * Replace encoded asterisk (*) back to literal. + // CloudStack’s internal encoder does not encode them; this results in an authentication failure for your API call. + // http://docs.cloudstack.apache.org/projects/archived-cloudstack-getting-started/en/latest/dev.html) // * Calculate HMAC SHA1 of argument string with CloudStack secret // * URL encode the string and convert to base64 s := encodeValues(params)