C
C
Extract XML string from a .p7m byte array (e.g. FATTURA ELETTRONICA, ITALY)
See more Digital Signatures Examples
_LANGUAGE_ example to extract the original XML from a .p7m (Signed-Data PKCS7 Format) provided as a byte array.One use for this example is to extract the original XML from a Fattura Elettronica .p7m signature.
Chilkat C Downloads
#include <C_CkFileAccess.h>
#include <C_CkByteData.h>
#include <C_CkCrypt2.h>
void ChilkatSample(void)
{
HCkFileAccess fac;
HCkByteData p7mBytes;
HCkCrypt2 crypt;
const char *originalXml;
// This example requires the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.
fac = CkFileAccess_Create();
p7mBytes = CkByteData_Create();
success = CkFileAccess_ReadEntireFile(fac,"testData/p7m/fattura_signature.p7m",p7mBytes);
if (CkFileAccess_getLastMethodSuccess(fac) != TRUE) {
printf("%s\n",CkFileAccess_lastErrorText(fac));
CkFileAccess_Dispose(fac);
CkByteData_Dispose(p7mBytes);
return;
}
crypt = CkCrypt2_Create();
originalXml = CkCrypt2_opaqueVerifyString(crypt,p7mBytes);
if (CkCrypt2_getLastMethodSuccess(crypt) != TRUE) {
printf("%s\n",CkFileAccess_lastErrorText(fac));
CkFileAccess_Dispose(fac);
CkByteData_Dispose(p7mBytes);
CkCrypt2_Dispose(crypt);
return;
}
printf("Original XML:\n");
printf("%s\n",originalXml);
printf("Success!\n");
CkFileAccess_Dispose(fac);
CkByteData_Dispose(p7mBytes);
CkCrypt2_Dispose(crypt);
}