Chilkat HOME .NET Core C# Android™ AutoIt C C# C++ Chilkat2-Python CkPython Classic ASP DataFlex Delphi ActiveX Delphi DLL Go Java Lianja Mono C# Node.js Objective-C PHP ActiveX PHP Extension Perl PowerBuilder PowerShell PureBasic Ruby SQL Server Swift 2 Swift 3,4,5... Tcl Unicode C Unicode C++ VB.NET VBScript Visual Basic 6.0 Visual FoxPro Xojo Plugin
(Unicode C) PKCS7 Decrypt Using .pfx or .p12 DataSee more MIME ExamplesDemonstrates how to decrypt MIME using a specifc PFX file (.pfx or .p12) for the source of certificate(s) and private key(s).
#include <C_CkMimeW.h> #include <C_CkByteData.h> #include <C_CkFileAccessW.h> void ChilkatSample(void) { HCkMimeW mime; BOOL success; HCkByteData pfxData; HCkFileAccessW fac; const wchar_t *pfxPassword; // This example assumes the Chilkat API to have been previously unlocked. // See Global Unlock Sample for sample code. mime = CkMimeW_Create(); // Load the MIME success = CkMimeW_LoadMimeFile(mime,L"encrypted.mim"); if (success == FALSE) { wprintf(L"%s\n",CkMimeW_lastErrorText(mime)); CkMimeW_Dispose(mime); return; } pfxData = CkByteData_Create(); fac = CkFileAccessW_Create(); success = CkFileAccessW_ReadEntireFile(fac,L"pfxStore/myPkcs12.p12",pfxData); if (CkFileAccessW_getLastMethodSuccess(fac) != TRUE) { wprintf(L"%s\n",CkFileAccessW_lastErrorText(fac)); CkMimeW_Dispose(mime); CkByteData_Dispose(pfxData); CkFileAccessW_Dispose(fac); return; } pfxPassword = L"myPassword"; success = CkMimeW_DecryptUsingPfxData(mime,pfxData,pfxPassword); if (success == FALSE) { wprintf(L"%s\n",CkMimeW_lastErrorText(mime)); CkMimeW_Dispose(mime); CkByteData_Dispose(pfxData); CkFileAccessW_Dispose(fac); return; } // Display the decrypted MIME: wprintf(L"%s\n",CkMimeW_getMime(mime)); // Note: The MIME to be decrypted should look something like this // when viewed in a text editor: // (Note that the Content-Type is application/x-pkcs7-mime) // Content-Disposition: attachment; filename="smime.p7m" // Content-Transfer-Encoding: base64 // Content-Type: application/x-pkcs7-mime; // name="smime.p7m" // // MIICRAYJKoZIhvcNAQcDoIICNTCCAjECAQAxggHIMIIBxAIBADCBqzCBlTELMAkGA1UEBhMCVVMx // CzAJBgNVBAgTAlVUMRcwFQYDVQQHEw5TYWx0IExha2UgQ2l0eTEeMBwGA1UEChMVVGhlIFVTRVJU // UlVTVCBOZXR3b3JrMSEwHwYDVQQLExhodHRwOi8vd3d3LnVzZXJ0cnVzdC5jb20xHTAbBgNVBAMT // FFVUTi1VU0VSRmlyc3QtT2JqZWN0AhEA5vxolKNrYgp1Z7ABICdK+zANBgkqhkiG9w0BAQEFAASC // AQAJ68jTh3u3ovsOuz1aHXTV90GBB6DMfCdx0bZ85trSvDXBevMOtQdctz653de8EB2xU4RlaPQa // oBpF8G01PMaKezd+FGLbhm7gmKl7boej3BboUzM4wrwjc8qHTGc/haT1ZA3jUU3DR4emVXNmRgWc // FDU5Dnkf+Z2YXQop9wPCf1Ng+8LLjBX9yxgXP1ZyFDe9vUnSkk2fmZatEY2Y6eWHNbrj6q4F40qN // PAyZW1rJSFmKTSPSzv7S0VWBMh+FgUKtqk4I6/+zhneLYeJBZFskmMIGFpgKdgrN7vbbr1a2gv/M // PbHUxwKMD4KZ2auyuGKMVLBOm+n8v5f8EegloL/UMGAGCSqGSIb3DQEHATAZBggqhkiG9w0DAjAN // AgE6BAgcohHNLdl9FoA4q22x8vXs05wuScRgLhwMOzvdGQkBJx+6iQDBuoCVxF8sQ35g+0PPxN3M // 6Zw6nI1gSIIKBS3ZjtI= CkMimeW_Dispose(mime); CkByteData_Dispose(pfxData); CkFileAccessW_Dispose(fac); } |
© 2000-2024 Chilkat Software, Inc. All Rights Reserved.