Sample code for 30+ languages & platforms
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

C++
#include <CkFileAccess.h>
#include <CkByteData.h>
#include <CkCrypt2.h>

void ChilkatSample(void)
    {
    //  This example requires the Chilkat API to have been previously unlocked.
    //  See Global Unlock Sample for sample code.

    CkFileAccess fac;
    CkByteData p7mBytes;
    success = fac.ReadEntireFile("testData/p7m/fattura_signature.p7m",p7mBytes);
    if (fac.get_LastMethodSuccess() != true) {
        std::cout << fac.lastErrorText() << "\r\n";
        return;
    }

    CkCrypt2 crypt;

    const char *originalXml = crypt.opaqueVerifyString(p7mBytes);
    if (crypt.get_LastMethodSuccess() != true) {
        std::cout << fac.lastErrorText() << "\r\n";
        return;
    }

    std::cout << "Original XML:" << "\r\n";
    std::cout << originalXml << "\r\n";

    std::cout << "Success!" << "\r\n";
    }