Chilkat
HOME
Android™
ASP
Visual Basic
VB.NET
C#
iOS (IPhone)
Objective-C
C++
C
MFC
Delphi
FoxPro
Java
Perl
PHP Extension
PHP ActiveX
Python
PowerShell
Ruby
SQL Server
VBScript
POP3 Verify Signed (S/MIME) EmailDemonstrates how to download and verify digitally signed S/MIME email. 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 FreeBSD C++ Libraries HP-UX C++ Libraries BlackBerry QNX C++ Libraries // Needs #include <CkMailMan.h> // Needs #include <CkStringArray.h> // Needs #include <CkEmail.h> // Needs #include <CkCert.h> CkString strOut; CkMailMan mailman; // Any string argument automatically begins the 30-day trial. bool success; success = mailman.UnlockComponent("30-day trial"); if (success != true) { strOut.append(mailman.lastErrorText()); strOut.append("\r\n"); SetDlgItemText(IDC_EDIT1,strOut.getUnicode()); return; } // Set the POP3 server's hostname mailman.put_MailHost("mail.chilkatsoft.com"); // Set the POP3 login/password. mailman.put_PopUsername("myLogin"); mailman.put_PopPassword("myPassword"); CkStringArray *sa = 0; sa = mailman.GetUidls(); if (sa == 0 ) { strOut.append(mailman.lastErrorText()); strOut.append("\r\n"); SetDlgItemText(IDC_EDIT1,strOut.getUnicode()); return; } long i; long n; n = sa->get_Count(); CkEmail *email = 0; const char * uidl; for (i = 0; i <= n - 1; i++) { uidl = sa->getString(i); email = mailman.FetchEmail(uidl); if (email == 0 ) { strOut.append(mailman.lastErrorText()); strOut.append("\r\n"); break; } strOut.append(email->ck_from()); strOut.append("\r\n"); strOut.append(email->subject()); strOut.append("\r\n"); // The security layers of signed and/or encrypted emails // are automatically "unwrapped" when loaded into // a Chilkat email object. // An application only needs to check to see if an email // was received signed or encrypted, and then examine // the success/failure. For example: if (email->get_ReceivedSigned() == true) { strOut.append("This email was signed."); strOut.append("\r\n"); // Check to see if the signatures were verified. if (email->get_SignaturesValid() == true) { strOut.append("Digital signature(s) verified."); strOut.append("\r\n"); strOut.append("Signer: "); strOut.append(email->signedBy()); strOut.append("\r\n"); // The certificate used for signing may be obtained // by calling email.GetSignedByCert. CkCert *cert = 0; cert = email->GetSignedByCert(); if (cert == 0 ) { strOut.append("Failed to get signing certificate object."); strOut.append("\r\n"); } else { strOut.append("Signing cert: "); strOut.append(cert->subjectCN()); strOut.append("\r\n"); delete cert; } } else { strOut.append("Digital signature verification failed."); strOut.append("\r\n"); } } delete email; } delete sa; mailman.Pop3EndSession(); SetDlgItemText(IDC_EDIT1,strOut.getUnicode()); |
Need a specific example? Send a request to support@chilkatsoft.com
© 2000-2010 Chilkat Software, Inc. All Rights Reserved.