aaxc Posted July 5, 2012 Report Share Posted July 5, 2012 (edited) Sveiki, esmu mazliet iestrēdzis ar Norvik bankas banklinku. Itkā vis ir sataisīts, bet brēc ka signature ir nepareiza. Lūk bankas atsūtītais "manuālis": Digital signature MAC is XML data hash value, encrypted with sender’s private key. For hash value calculations SHA-1 algorithm is used, but for signature calculation RSA algorithm is used. Digital signature transforms to textual format using BASE64 encoding and is placed to MAC field. Mans kods: private function setPrivateKey ( $key_name ) { $fp = fopen( $this -> getKeyLocation() . '/' . $key_name, "r" ); $priv_key = fread( $fp, 8192 ); fclose( $fp ); $this -> private_key = openssl_get_privatekey( $priv_key ); } private function setSignature () { $pre_mac = sha1( $this -> getXMLData() ); openssl_sign( $pre_mac, $signature, $this -> getPrivateKey() ); $this -> signature = $signature; } private function setMac () { $this -> mac = base64_encode( $this -> getSignature() ); } Vai es kautko ne tā taisu? Itkā jau viss pēc manuāļa, bet signature šamajiem nepatīk. Ar citām bankām šādu problēmu nav, vis strādā normāli. Ja kāds ir taisījis Norvik bankai tieši, varētu padalīties ar pieredzi. Paldies jau iepriekš. Edited July 6, 2012 by aaxc Quote Link to comment Share on other sites More sharing options...
anonīms Posted July 5, 2012 Report Share Posted July 5, 2012 <pre class="prettyprint" style="margin-top: 0px; margin-bottom: 0px; margin-left: 10px; padding: 5px; background-color: rgb(248, 248, 248); border: 1px solid rgb(201, 201, 201); overflow: auto; font-size: 11px; line-height: 15px; color: rgb(40, 40, 40); ">getSignature</pre> kas te? Quote Link to comment Share on other sites More sharing options...
aaxc Posted July 5, 2012 Author Report Share Posted July 5, 2012 get ir parastas return funkcijas: private function getSignature () { return $this -> signature; } Quote Link to comment Share on other sites More sharing options...
v3rb0 Posted July 5, 2012 Report Share Posted July 5, 2012 xml datos utf8? kaut kas saistīts ar šo - http://stackoverflow.com/questions/790232/c-sharp-sha-1-vs-php-sha-1-different-results ? Quote Link to comment Share on other sites More sharing options...
aaxc Posted July 5, 2012 Author Report Share Posted July 5, 2012 XML nesatur special chars, tākā kodējums nav svarīgs + pirms signatures izdampojot XML viss uzrādas pareizi, tākā ar datiem vis itkā kārtībā. Quote Link to comment Share on other sites More sharing options...
Aleksejs Posted July 6, 2012 Report Share Posted July 6, 2012 Man kaut kā nešķiet, ka ir pareiza secība. Cik no teksta saprotu, tad secībai ir jābūt šādai: openssl_sign(sha1(data)) bet kodā šķiet, ka ir: sha1(openssl_sign(data)) Quote Link to comment Share on other sites More sharing options...
aaxc Posted July 6, 2012 Author Report Share Posted July 6, 2012 private function setSignature () { $pre_mac = sha1( $this -> getXMLData() ); openssl_sign( $pre_mac, $signature, $this -> getPrivateKey() ); $this -> signature = $signature; } Ka redzi sākumā notiek sha1 un pēc tam sign, tākā sanāk openssl_sign( sha1( data ) ) Quote Link to comment Share on other sites More sharing options...
Aleksejs Posted July 6, 2012 Report Share Posted July 6, 2012 Ā - ok. vēl jautājums... By Default sha1 izdod hexadecimālā formātā, vai nevajag, lai izdod raw? sha1($data,true); ? Quote Link to comment Share on other sites More sharing options...
aaxc Posted July 6, 2012 Author Report Share Posted July 6, 2012 Notestēju, bez izmaiņām. Tikko nosūtīju bankai to visu garo penteri, redzēs ko šī atbildēs. Negribējās, bet citu variantu laikam nav. Quote Link to comment Share on other sites More sharing options...
aaxc Posted July 6, 2012 Author Report Share Posted July 6, 2012 Ok, problem solved, kādām būtu jāiemāca rakstīt manuāļus ... novācu lieki pieminēto hashingu un vis aizgāja: private function setSignature () { openssl_sign( $this -> getXMLData(), $signature, $this -> getPrivateKey() ); $this -> signature = $signature; } Quote Link to comment Share on other sites More sharing options...
aaxc Posted July 6, 2012 Author Report Share Posted July 6, 2012 PS: Ja kādam interesē, man ir doma uztaisīt manuāli pa nedēļas nogali. Tagad tik returns vēl jāapstrādā sākumā. Quote Link to comment Share on other sites More sharing options...
Kracker Posted July 10, 2012 Report Share Posted July 10, 2012 Kad manuālis būs gatavs, iemet šeit! Paldies! Quote Link to comment Share on other sites More sharing options...
aaxc Posted July 16, 2012 Author Report Share Posted July 16, 2012 (edited) Manuālis aizkavējies, jo nezkāpēc nestrādā prod versija. Ar demo sistēmu vis šancē perfekti. Palaižot live kautkas nav tā. Gaidu jau gandrīz 2 nedēļas no bankas atbildi :) Edited July 16, 2012 by aaxc Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.