Unicode C
Unicode C
Clear the S/MIME Recipient Certificate List
See more MIME Examples
Demonstrates ClearEncryptCerts, which empties the recipient-certificate list previously populated by AddEncryptCert. This is useful to start over with a different set of recipients before calling EncryptN.
Background. The recipient list is internal state that accumulates across AddEncryptCert calls. ClearEncryptCerts resets it so a subsequent EncryptN encrypts only for the certificates added afterward.
Chilkat Unicode C Downloads
#include <C_CkMimeW.h>
#include <C_CkCertW.h>
void ChilkatSample(void)
{
BOOL success;
HCkMimeW mime;
HCkCertW cert;
success = FALSE;
mime = CkMimeW_Create();
success = CkMimeW_SetBodyFromPlainText(mime,L"This message will be encrypted.");
if (success == FALSE) {
wprintf(L"%s\n",CkMimeW_lastErrorText(mime));
CkMimeW_Dispose(mime);
return;
}
// Add a recipient certificate.
cert = CkCertW_Create();
success = CkCertW_LoadFromFile(cert,L"qa_data/recipient.cer");
if (success == FALSE) {
wprintf(L"%s\n",CkCertW_lastErrorText(cert));
CkMimeW_Dispose(mime);
CkCertW_Dispose(cert);
return;
}
success = CkMimeW_AddEncryptCert(mime,cert);
if (success == FALSE) {
wprintf(L"%s\n",CkMimeW_lastErrorText(mime));
CkMimeW_Dispose(mime);
CkCertW_Dispose(cert);
return;
}
// ClearEncryptCerts empties the recipient-certificate list, for example to start over with a
// different set of recipients before calling EncryptN. It is a void method.
CkMimeW_ClearEncryptCerts(mime);
wprintf(L"Recipient certificate list cleared.\n");
CkMimeW_Dispose(mime);
CkCertW_Dispose(cert);
}