andrew-svirin / ebics-client-php

PHP library to make requests by EBICS protocol for financial establishments. Support EBICS versions: 2.4, 2.5, 3.0; Encryption versions: E002, X002, A005, A006; Switching EBICS T/TS.
https://andrew-svirin.github.io/ebics-client-php/
MIT License
44 stars 32 forks source link

Decryption failed reading BTD with Monte dei Paschi di Siena banque in EBICS V3 #201

Open NanoNao opened 4 days ago

NanoNao commented 4 days ago

Hello everyone.

I'm currently trying to read a CFONB120 for a BTP response. Unfortunately, the library catches a LogicException with this error message “Decryption failed”. I use EBICS 3.0

I've already used this library with another bank and everything was OK. I've already tried to solve this problem with the bank. But nobody has an answer to this problem.

I don't really know where to start looking or what to look for. I don't even know if the problem is with the lib or the bank. Do you have any clues about this problem?

Thank you and have a nice day

Version : 2.x-dev Not using password for this test.

andrew-svirin commented 4 days ago

Hello @NanoNao what version of library do you use?

NanoNao commented 4 days ago

Im using 2.x-dev

NanoNao commented 4 days ago

For more information, the error occurs in “decryptOrderDataCompressed” when the “decryptByKey” method is called. I wonder if $transactionKeyDecrypted is correct.

andrew-svirin commented 4 days ago

You can try to updated keyring by next:

$hpb = $client->HPB();
$keyringManager = new FileKeyringManager();
$keyringManager->saveKeyring($client->getKeyring(), $keyringRealPath);

And check if keyring file was modified.

NanoNao commented 4 days ago

Thanks for your reply.

I've already tried it. I even created a new ebics contract with the . But I always get this error.

My main question is whether it's a problem with the lib or the data sent by the bank.

NanoNao commented 4 days ago

$transactionKeyDecrypted length is 16long, it should be 128 according to $aes->setKeyLength(128); or am I wrong ?

andrew-svirin commented 4 days ago

I believe this is the error with the lib. Should be investigated this scenario. Does HPB responses correctly?

NanoNao commented 4 days ago

I've just checked and it seems that the keys in my keyring are correct.

In decryptOrderDataCompressed() my $signatureE->getPrivateKey() seem to be good (same as send in HPB) I use empty string password so maybe we can exclude this probleme too.

Also i can decode data send in HPB with this same methode, so we can exclude problème with myPrivateKey.

andrew-svirin commented 4 days ago

It could happen with wrong password. Try to settle password by

$client->changeKeyringPassword('some_new_password');