Sample code for 30+ languages & platforms
Unicode C

Example: Crypt2.LastSignerCert method

Demonstrates how to call the LastSignerCert method.

Chilkat Unicode C Downloads

Unicode C
#include <C_CkCrypt2W.h>
#include <C_CkCertW.h>

void ChilkatSample(void)
    {
    BOOL success;
    HCkCrypt2W crypt;
    const wchar_t *p7m_path;
    const wchar_t *out_path;
    int numSigners;
    int i;
    HCkCertW cert;

    success = FALSE;

    crypt = CkCrypt2W_Create();

    p7m_path = L"qa_data/p7m/Firma.docx.p7m";
    out_path = L"qa_output/Firma.docx";

    success = CkCrypt2W_VerifyP7M(crypt,p7m_path,out_path);
    if (success == FALSE) {
        wprintf(L"%s\n",CkCrypt2W_lastErrorText(crypt));
        CkCrypt2W_Dispose(crypt);
        return;
    }

    //  Examine the certificate(s) used for signing.
    numSigners = CkCrypt2W_getNumSignerCerts(crypt);
    i = 0;

    cert = CkCertW_Create();

    while (i < numSigners) {
        CkCrypt2W_LastSignerCert(crypt,i,cert);
        wprintf(L"Signer: %s\n",CkCertW_subjectDN(cert));
        i = i + 1;
    }



    CkCrypt2W_Dispose(crypt);
    CkCertW_Dispose(cert);

    }