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

Objective-C
#import <CkoCrypt2.h>
#import <CkoJsonObject.h>
#import <NSString.h>

BOOL success = NO;

CkoCrypt2 *crypt = [[CkoCrypt2 alloc] init];

//  Tell Chilkat to also validate the timestamp token if a timestamp exists in the CMS message's unauthenticated attributes.
CkoJsonObject *cmsOptions = [[CkoJsonObject alloc] init];
[cmsOptions UpdateBool: @"ValidateTimestampTokens" value: YES];
crypt.CmsOptions = [cmsOptions Emit];

NSString *outputFile = @"qa_output/original.xml";
NSString *inFile = @"qa_data/p7m/fattura_signature.xml.p7m";

//  Verify the signature and extract the contained file, which in this case is XML.
success = [crypt VerifyP7M: inFile destPath: outputFile];
if (success == NO) {
    NSLog(@"%@",crypt.LastErrorText);
    return;
}

NSLog(@"%@",@"Signature validated.");