Chilkat HOME ASP Visual Basic VB.NET C# Visual C++ C MFC Delphi FoxPro Java Perl PHP Python Ruby SQL Server VBScript
|
Create S/MIME Detached Signature with PFXHow to use a PFX to create a signed S/MIME message.
#include <CkMime.h> #include <CkCertStore.h> #include <CkString.h> #include <CkCert.h> void ChilkatSample(void) { CkMime mime; bool success; success = mime.UnlockComponent("Anything for 30-day trial"); if (success == false) { printf("Failed to unlock component\n"); return; } mime.AddHeaderField("Subject","This is a test"); mime.AddHeaderField("Abc","123"); mime.SetBodyFromPlainText("This is the body"); CkCertStore certStore; CkString password; password = "myPassword"; success = certStore.LoadPfxFile("chilkat.pfx",password); if (success == false) { printf("%s\n",certStore.lastErrorText()); return; } CkCert *cert = 0; cert = certStore.FindCertBySubjectCN("Chilkat Software, Inc."); if (cert == 0 ) { printf("Failed to find certificate!\n"); return; } // Display the full distinguished name of the cert. printf("%s\n",cert->subjectDN()); success = mime.AddDetachedSignature(*cert); if (success == false) { printf("%s\n",mime.lastErrorText()); return; } delete cert; printf("%s\n",mime.getMime()); } |
Need a specific example? Send a request to support@chilkatsoft.com
© 2000-2008 Chilkat Software, Inc. All Rights Reserved.