![]() |
Chilkat HOME Android™ AutoIt C C# C++ Chilkat2-Python CkPython Classic ASP DataFlex Delphi DLL Go Java Node.js Objective-C PHP Extension Perl PowerBuilder PowerShell PureBasic Ruby SQL Server Swift Tcl Unicode C Unicode C++ VB.NET VBScript Visual Basic 6.0 Visual FoxPro Xojo Plugin
Decrypt MIME with PFX
Demonstrates 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" <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> </head> <body> <% set mime = Server.CreateObject("Chilkat_9_5_0.Mime") success = mime.UnlockComponent("Anything for 30-day trial") If (success = 0) Then Response.Write "<pre>" & Server.HTMLEncode("Failed to unlock component") & "</pre>" End If success = mime.LoadMimeFile("encryptedEmail.eml") If (success <> 1) Then Response.Write "<pre>" & Server.HTMLEncode( mime.LastErrorText) & "</pre>" End If set certStore = Server.CreateObject("Chilkat_9_5_0.CertStore") success = certStore.LoadPfxFile("myPfx.pfx","myPfxPassword") If (success <> 1) Then Response.Write "<pre>" & Server.HTMLEncode( certStore.LastErrorText) & "</pre>" End If ' Find the certificate by email address. There are many ' ways to find certificates within a Chilkat certificate store ' object... ' cert is a Chilkat_9_5_0.Cert Set cert = certStore.FindCertBySubjectE("support@chilkatsoft.com") If (cert Is Nothing ) Then Response.Write "<pre>" & Server.HTMLEncode( certStore.LastErrorText) & "</pre>" End If ' privKey is a Chilkat_9_5_0.PrivateKey Set privKey = cert.ExportPrivateKey() If (privKey Is Nothing ) Then Response.Write "<pre>" & Server.HTMLEncode( cert.LastErrorText) & "</pre>" End If success = mime.Decrypt2(cert,privKey) If (success <> 1) Then Response.Write "<pre>" & Server.HTMLEncode( mime.LastErrorText) & "</pre>" End If ' Show the decrypted MIME: Response.Write "<pre>" & Server.HTMLEncode( mime.GetMime()) & "</pre>" %> </body> </html> |
||||
© 2000-2026 Chilkat Software, Inc. All Rights Reserved.