Sample code for 30+ languages & platforms
Unicode C

Check for an S/MIME Signing Time

See more MIME Examples

Demonstrates the Chilkat Mime.HasSignatureSigningTime method, which returns whether the signer at a zero-based index included a CMS signingTime signed attribute. The only argument is the signer index; use NumSignerCerts for the count.

Note: The file paths are relative to the application's current working directory. Absolute paths may also be used. Supply the paths appropriate to your own environment.

Background: A signing time records when the signer claims to have signed, which matters for auditing and for validating a certificate that has since expired. It is an optional signed attribute, so not every signature has one — this predicate lets you check before calling GetSignatureSigningTimeStr, avoiding an error for signers that omitted it. Being a signed attribute, it is covered by the signature and cannot be altered undetected.

Chilkat Unicode C Downloads

Unicode C
#include <C_CkMimeW.h>

void ChilkatSample(void)
    {
    BOOL success;
    HCkMimeW mime;
    int n;
    int i;

    success = FALSE;

    mime = CkMimeW_Create();
    success = CkMimeW_LoadMimeFile(mime,L"qa_data/signed.eml");
    if (success == FALSE) {
        wprintf(L"%s\n",CkMimeW_lastErrorText(mime));
        CkMimeW_Dispose(mime);
        return;
    }

    //  After verifying, check whether each signer included a CMS signingTime signed attribute.  The
    //  only argument is the zero-based signer index.
    success = CkMimeW_Verify(mime);
    if (success != TRUE) {
        wprintf(L"%s\n",CkMimeW_lastErrorText(mime));
        CkMimeW_Dispose(mime);
        return;
    }

    n = CkMimeW_getNumSignerCerts(mime);

    for (i = 0; i <= n - 1; i++) {
        if (CkMimeW_HasSignatureSigningTime(mime,i)) {
            wprintf(L"Signer %d included a signing time.\n",i);
        }
        else {
            wprintf(L"Signer %d did not include a signing time.\n",i);
        }

    }



    CkMimeW_Dispose(mime);

    }