Chilkat HOME Android™ Classic ASP C C++ C# Mono C# .NET Core C# C# UWP/WinRT DataFlex Delphi ActiveX Delphi DLL Visual FoxPro Java Lianja MFC Objective-C Perl PHP ActiveX PHP Extension PowerBuilder PowerShell PureBasic CkPython Chilkat2-Python Ruby SQL Server Swift 2 Swift 3,4,5... Tcl Unicode C Unicode C++ Visual Basic 6.0 VB.NET VB.NET UWP/WinRT VBScript Xojo Plugin Node.js Excel Go
(MFC) Add S/MIME Signature using PFXAdd a digital signature to a MIME message using the certificate + private key from a PFX file.
#include <CkMime.h> #include <CkCert.h> void ChilkatSample(void) { CkString strOut; // This example requires the Chilkat API to have been previously unlocked. // See Global Unlock Sample for sample code. CkMime mime; // Load a PFX file into a certificate object. CkCert cert; const char *pfxFilepath = "pfxFiles/something.pfx"; const char *pfxPassword = "secret"; bool success = cert.LoadPfxFile(pfxFilepath,pfxPassword); if (success == false) { strOut.append(cert.lastErrorText()); strOut.append("\r\n"); SetDlgItemText(IDC_EDIT1,strOut.getUnicode()); return; } success = mime.SetBodyFromPlainText("This is the plain-text MIME body."); mime.put_Charset("utf-8"); mime.put_Encoding("quoted-printable"); // Sign the MIME (adds a PKCS7 detached signature) success = mime.AddDetachedSignature(cert); if (success == false) { strOut.append(mime.lastErrorText()); strOut.append("\r\n"); SetDlgItemText(IDC_EDIT1,strOut.getUnicode()); return; } // Save the S/MIME to a file. success = mime.SaveMime("/temp/signedMime.txt"); if (success == false) { strOut.append(mime.lastErrorText()); strOut.append("\r\n"); SetDlgItemText(IDC_EDIT1,strOut.getUnicode()); return; } strOut.append("success!"); strOut.append("\r\n"); SetDlgItemText(IDC_EDIT1,strOut.getUnicode()); } |
© 2000-2022 Chilkat Software, Inc. All Rights Reserved.