Hi Nux!, Thanks for the link, we will look into that.
It's just an interesting issue, part of the fun of it though. I will keep working on it and post any findings. Thanks, Blake -----Original Message----- From: Nux! [mailto:[email protected]] Sent: Monday, March 30, 2015 11:35 AM To: [email protected] Subject: Re: API Signing Issue You might be able to "bypass" the problem by using the integration port (make sure to firewall it as it allows non-auth requests), though I'd also be curious for a solution. https://cloudstack.apache.org/docs/en-US/Apache_CloudStack/4.0.0-incubating/html-single/API_Developers_Guide/#enabling-port-8096 -- Sent from the Delta quadrant using Borg technology! Nux! www.nux.ro ----- Original Message ----- > From: "Blake Ferkingstad" <[email protected]> > To: [email protected] > Sent: Monday, 30 March, 2015 16:17:23 > Subject: API Signing Issue > Hello everyone, > > > > I have a question on my API Signing code. The code below I have tested > on commands like createDomain, listTemplates, and listServices. Those > all run like expected, but I am running into trouble with createAccount. > > > > function cloudstack_sign_sort($cmd) > > { > > $commands = explode('&', $cmd); > > sort($commands); > > $sort = implode('&', $commands); > > > > return $sort; > > } > > > > function cloudstack_formatCmd($api, $cmd) { > > $str = 'apiKey=' . $api . '&' . $cmd; > > $str = strtolower(cloudstack_sign_sort($str)); > > > > return $str; > > } > > > > function cloudstack_encrypt($cmd, $secret) { > > $hash = hash_hmac('sha1', $cmd, $secret, true); > > $hash = base64_encode($hash); > > > > return urlencode($hash); > > } > > > > function cloudstack_formattedUrl($baseUrl, $api, $cmd, $signature) { > > $url = $baseUrl . '?' . $cmd . '&apiKey=' . $api . '&signature=' . > $signature; > > > > return $url; > > } > > > > function cloudstack_sign($command, $api, $secret, $baseUrl) { > > $clean_command = substr($command, strpos($command, '?')); > > > > $newCmd = cloudstack_formatCmd($api, $clean_command); > > $signature = cloudstack_encrypt($newCmd, $secret); > > $url = cloudstack_formattedUrl($baseUrl, $api, $clean_command, > $signature); > > > > return $url; > > } > > > > When I run the command it returns for createAccount I get 'Error: > 401unable to verify user credentials and/or request signature'. > > > > Is there something wrong with my code? > > > > Thanks, > > Blake Ferkingstad
