Hello,
We are using your TMS Cryptography Pack for integration with KSeF in Poland.
We successfully implemented everything using version 4.3.3.0 in the C++ Builder 10.2 Tokyo.
Now, we have updated to C++ Builder 13 and TMS Crypto 5.1.1.9, and we are encountering an issue with the TXAdES object.
Our code previously looked like this and used a key file that was already decrypted:
xades->Packaging = enveloping;
xades->KeyFilePath = ExtractFilePath(Application->ExeName) + "KSeF\\klucz.key";
xades->CertFilePath = ExtractFilePath(Application->ExeName) + "KSeF\\certyfikat.crt";
xades->GenerateSignature(ExtractFilePath(Application->ExeName) + "KSeF\\xades.xml", ExtractFilePath(Application->ExeName) + "KSeF\\podpisany.xml");
The code above worked very well but required the key file to be decrypted beforehand.
In the new version of TMS Crypto, it is possible to provide a password and use the original key file. We therefore modified our code as follows:
// xades->Packaging = enveloping;
xades->Packaging = enveloped;
// poniżej dodano
xades->PKCS11Param->isToken = false;
xades->Password = "PasswordToKeyFile!";
xades->Template = xPlEnveloped;
xades->KeyFilePath = ExtractFilePath(Application->ExeName) + "KSeF\klucz_org.key";
xades->CertFilePath = ExtractFilePath(Application->ExeName) + "KSeF\\crt_org.crt";
xades->GenerateSignature(ExtractFilePath(Application->ExeName) + "KSeF\\xades.xml", ExtractFilePath(Application->ExeName) + "KSeF\\podpisany.xml");
After this modification, the GenerateSignature() function triggers an Access Violation error.
We found a forum thread discussing this error:
XAdES problem - polish KSEF - C++Builder - 5.1.0.4 - #2 by Bernard
The solution provided there does not work, as the latest version of TMS Crypto does not contain the line:
inherited Create(Self);
Naturally, we are using the original encrypted key file in the new version.
What could be the problem here?
We also have an additional question. Can the new version of TMS Crypto - like the old version 4.3.3.0 - use key files that have already been decrypted? If so, how? Providing an empty password does not work.
Thank you in advance for your help.