Chilkat HOME ASP Visual Basic VB.NET C# C C++ MFC Delphi FoxPro Java Perl Python Ruby SQL Server VBScript
Decrypt MIME with PFXDemonstrates how to decrypt MIME using a PFX (containing a digital certificate with private key). The content-type of an encrypted MIME message looks like this: Content-Type: application/x-pkcs7-mime; name="smime.p7m" <?php $mime = new COM("Chilkat.Mime"); $success = $mime->UnlockComponent('Anything for 30-day trial'); if ($success == false) { print 'Failed to unlock component' . "\n"; exit; } $success = $mime->LoadMimeFile('encryptedEmail.eml'); if ($success != true) { print $mime->lastErrorText() . "\n"; exit; } $certStore = new COM("Chilkat.CertStore"); $success = $certStore->LoadPfxFile('myPfx.pfx','myPfxPassword'); if ($success != true) { print $certStore->lastErrorText() . "\n"; exit; } // Find the certificate by email address. There are many // ways to find certificates within a Chilkat certificate store // object... // cert is a Chilkat.Cert $cert = $certStore->FindCertBySubjectE('support@chilkatsoft.com'); if (is_null($cert)) { print $certStore->lastErrorText() . "\n"; exit; } // privKey is a Chilkat.PrivateKey $privKey = $cert->ExportPrivateKey(); if (is_null($privKey)) { print $cert->lastErrorText() . "\n"; exit; } $success = $mime->Decrypt2($cert,$privKey); if ($success != true) { print $mime->lastErrorText() . "\n"; exit; } // Show the decrypted MIME: print $mime->getMime() . "\n"; ?> |
Need a specific example? Send a request to support@chilkatsoft.com
© 2000-2010 Chilkat Software, Inc. All Rights Reserved.