(C) Example: Crypt2.LastSignerCert method
Demonstrates how to call the LastSignerCert method. Note: This example requires Chilkat v11.0.0 or greater.
#include <C_CkCrypt2.h>
#include <C_CkCert.h>
void ChilkatSample(void)
{
HCkCrypt2 crypt;
const char *p7m_path;
const char *out_path;
BOOL success;
int numSigners;
int i;
HCkCert cert;
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);
}
|