Unicode C
Unicode C
Verify the Timestamp Server Token (if any) while Validating a CMS Signature
Demonstrates how to also validate the timestamp server token (if any) while validating a CMS signature.Chilkat Unicode C Downloads
#include <C_CkCrypt2W.h>
#include <C_CkJsonObjectW.h>
void ChilkatSample(void)
{
BOOL success;
HCkCrypt2W crypt;
HCkJsonObjectW cmsOptions;
const wchar_t *outputFile;
const wchar_t *inFile;
success = FALSE;
crypt = CkCrypt2W_Create();
// Tell Chilkat to also validate the timestamp token if a timestamp exists in the CMS message's unauthenticated attributes.
cmsOptions = CkJsonObjectW_Create();
CkJsonObjectW_UpdateBool(cmsOptions,L"ValidateTimestampTokens",TRUE);
CkCrypt2W_putCmsOptions(crypt,CkJsonObjectW_emit(cmsOptions));
outputFile = L"qa_output/original.xml";
inFile = L"qa_data/p7m/fattura_signature.xml.p7m";
// Verify the signature and extract the contained file, which in this case is XML.
success = CkCrypt2W_VerifyP7M(crypt,inFile,outputFile);
if (success == FALSE) {
wprintf(L"%s\n",CkCrypt2W_lastErrorText(crypt));
CkCrypt2W_Dispose(crypt);
CkJsonObjectW_Dispose(cmsOptions);
return;
}
wprintf(L"Signature validated.\n");
CkCrypt2W_Dispose(crypt);
CkJsonObjectW_Dispose(cmsOptions);
}