satis egitimisatis egitimitengda.pro
Welcome, Guest
Username: Password: Remember me
Archived CloudStack Forums for reference purposes please direct all future inquiries to the Apache CloudStack mailing lists.

incubator.apache.org/cloudstack/mailing-lists.html
  • Page:
  • 1
  • 2

TOPIC: Signature with php problem

Signature with php problem 2 years 17 hours ago #9128

  • gogogokrit
  • gogogokrit's Avatar
  • OFFLINE
  • Fresh Boarder
  • Posts: 6
  • Karma: 0
hi, i study CloudStack API and i got problem about Signature

when i generate signature with php there are invalid. So i use snumano .pl script they work correctly

i try to read code and compare result step by step both php and perl.

i got that same command string with lowercase to hash_hmac(both php and perl script) result are different
(php i use output binary option is true)

any recommend about implement in php code to generate signature?
The administrator has disabled public write access.

Re: Signature with php problem 1 year 11 months ago #9191

  • dlafferty
  • dlafferty's Avatar
  • OFFLINE
  • Fresh Boarder
  • Posts: 9
  • Thank you received: 1
  • Karma: 0
First, are you using "sha1" as your hash_algos? (See www.php.net/manual/en/function.hash-algos.php for hash_algos options)


Secondly, are the results different coming out of hash_hmac, or after urlencoding?

E.g. if you compare raw output, you may find that the urlencoding varies due to capitalisation. E.g. my unit test for query signing in python generates

bjQMCeOIYj0HbN2Yktt7%2FV4PpIU%3D

in c# it generates

bjQMCeOIYj0HbN2Yktt7%2fV4PpIU%3d

I.e. python uses "%3D", whereas .NET uses "%3d"
The administrator has disabled public write access.
The following user(s) said Thank You: ke4qqq

Re: Signature with php problem 1 year 11 months ago #9193

  • gogogokrit
  • gogogokrit's Avatar
  • OFFLINE
  • Fresh Boarder
  • Posts: 6
  • Karma: 0
at same command (lowercase and sorted)

compare between php and perl script

result is different from hash_hmac function (hex64 output is same but on binary output is problem)
The administrator has disabled public write access.

Re: Signature with php problem 1 year 11 months ago #9200

  • dlafferty
  • dlafferty's Avatar
  • OFFLINE
  • Fresh Boarder
  • Posts: 9
  • Thank you received: 1
  • Karma: 0
Use the hex64 output. AFAIK, you can't transmit the binary data in an HTTP Query. For background, see tools.ietf.org/html/rfc2616#section-3.2
The administrator has disabled public write access.

Re: Signature with php problem 1 year 11 months ago #9250

  • gogogokrit
  • gogogokrit's Avatar
  • OFFLINE
  • Fresh Boarder
  • Posts: 6
  • Karma: 0
I mean when i compare binary result is not same because to create signature in php is about

ex.

$command = "command=listIsos";
$apikey = "xxxxxxxx";
$sercretkey = "yyyyyyyy";

$hash = hash_hmac("sha1",strtolower($apikey . "&" . $command),$secretkey.true); <--- output doesn't same as perl script
$base64 = base64_encode($hash);
$signature = urlencode($base64);

then I use generated signature it say incorrect signature.
The administrator has disabled public write access.

Re: Signature with php problem 1 year 11 months ago #9273

  • dlafferty
  • dlafferty's Avatar
  • OFFLINE
  • Fresh Boarder
  • Posts: 9
  • Thank you received: 1
  • Karma: 0
Fine, but my suggestion was to use

hash_hmac("sha1",strtolower($apikey . "&" . $command),$secretkey.true, $raw_output = false);

Does that generate to signature acceptable to CloudStack?
The administrator has disabled public write access.
  • Page:
  • 1
  • 2
Time to create page: 0.303 seconds

Open@Citrix

Citrix supports the open source community via developer support and evangeslism. We have a number of developers and evangelists that participate actively in the open source community in Apache Cloudstack, OpenDaylight, Xen Project and XenServer. We also conduct educational activities via the Build A Cloud events held all over the world. 

Connect