Chilkat HOME .NET Core C# Android™ AutoIt C C# C++ Chilkat2-Python CkPython Classic ASP DataFlex Delphi ActiveX Delphi DLL Go Java Lianja Mono C# Node.js Objective-C PHP ActiveX PHP Extension Perl PowerBuilder PowerShell PureBasic Ruby SQL Server Swift 2 Swift 3,4,5... Tcl Unicode C Unicode C++ VB.NET VBScript Visual Basic 6.0 Visual FoxPro Xojo Plugin
(Unicode C) Extract XML from FatturaPA .p7mDemonstrates how to verify the signature and extract the XML from a FatturaPA .p7m file.
#include <C_CkBinDataW.h> #include <C_CkCrypt2W.h> #include <C_CkXmlW.h> void ChilkatSample(void) { HCkBinDataW bd; BOOL success; HCkCrypt2W crypt; BOOL bVerified; HCkXmlW xml; // This example requires the Chilkat API to have been previously unlocked. // See Global Unlock Sample for sample code. bd = CkBinDataW_Create(); success = CkBinDataW_LoadFile(bd,L"qa_data/p7m/IT01879020517_abc.xml.p7m"); if (success != TRUE) { wprintf(L"Failed to load the .p7m file\n"); CkBinDataW_Dispose(bd); return; } crypt = CkCrypt2W_Create(); // Verify and extrct the payload contained within the .p7m. // In this case, the payload is the FatturaPA XML. // If successful, the resulting bd will contain only the XML. bVerified = CkCrypt2W_OpaqueVerifyBd(crypt,bd); if (bVerified != TRUE) { wprintf(L"%s\n",CkCrypt2W_lastErrorText(crypt)); wprintf(L"Failed to extract and verify.\n"); CkBinDataW_Dispose(bd); CkCrypt2W_Dispose(crypt); return; } // Save the XML to a file. CkBinDataW_WriteFile(bd,L"qa_output/zIT01879020517_abc.xml"); // Alternatively, load into an XML object and emit. xml = CkXmlW_Create(); CkXmlW_LoadXml(xml,CkBinDataW_getString(bd,L"utf-8")); wprintf(L"%s\n",CkXmlW_getXml(xml)); CkBinDataW_Dispose(bd); CkCrypt2W_Dispose(crypt); CkXmlW_Dispose(xml); } |
© 2000-2024 Chilkat Software, Inc. All Rights Reserved.