Visual C++ Examples

ChilkatHOMEAndroid™ASPVisual BasicVB.NETC#iOS (IPhone)Objective-CC++CMFCDelphiFoxProJavaPerl
PHP ExtensionPHP ActiveXPythonPowerShellRubySQL ServerVBScript

C++ Examples

CkString
Byte Array
Bounced Mail
Bz2
Character Encoding
CSV
DH Key Exchange
DKIM/DomainKeys
Digital Certificates
Digital Signatures
DSA
Email
Email Object
Encryption
FTP
HTML Conversion
HTTP
IMAP
MHT / HTML Email
POP3
RSA
S/MIME
SMTP
Socket
Spider
SSH Key
SSH
SSH Tunnel
SFTP
Tar
Upload
XML
XMP
Zip Compression


More Examples...
Amazon S3
NTLM
FileAccess
RSS
Atom
Self-Extractor
Service
PPMD
Deflate
Bzip2
LZW

 

 

 

 

 

 

 

 

Create S/MIME Detached Signature with PFX

How to use a PFX to create a signed S/MIME message.

Downloads:

MS Windows Visual C/C++ Libraries
Linux/CentOS C/C++ Libraries
MAC OS X C/C++ Libraries
Solaris C/C++ Libraries
C++ Builder Libraries
#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());


    }

© 2000-2010 Chilkat Software, Inc. All Rights Reserved.

Mail Component · .NET Mail Component · XML Parser