Sample code for 30+ languages & platforms
C

Example: Crypt2.LastSignerCert method

Demonstrates how to call the LastSignerCert method.

Chilkat C Downloads

C
#include <C_CkCrypt2.h>
#include <C_CkCert.h>

void ChilkatSample(void)
    {
    BOOL success;
    HCkCrypt2 crypt;
    const char *p7m_path;
    const char *out_path;
    int numSigners;
    int i;
    HCkCert cert;

    success = FALSE;

    crypt = CkCrypt2_Create();

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

    success = CkCrypt2_VerifyP7M(crypt,p7m_path,out_path);
    if (success == FALSE) {
        printf("%s\n",CkCrypt2_lastErrorText(crypt));
        CkCrypt2_Dispose(crypt);
        return;
    }

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

    cert = CkCert_Create();

    while (i < numSigners) {
        CkCrypt2_LastSignerCert(crypt,i,cert);
        printf("Signer: %s\n",CkCert_subjectDN(cert));
        i = i + 1;
    }



    CkCrypt2_Dispose(crypt);
    CkCert_Dispose(cert);

    }