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
|
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" CREATE PROCEDURE ChilkatSample AS BEGIN DECLARE @hr int DECLARE @sTmp0 nvarchar(4000) DECLARE @mime int EXEC @hr = sp_OACreate 'Chilkat.Mime', @mime OUT IF @hr <> 0 BEGIN PRINT 'Failed to create ActiveX component' RETURN END DECLARE @success int EXEC sp_OAMethod @mime, 'UnlockComponent', @success OUT, 'Anything for 30-day trial' IF @success = 0 BEGIN PRINT 'Failed to unlock component' RETURN END EXEC sp_OAMethod @mime, 'LoadMimeFile', @success OUT, 'encryptedEmail.eml' IF @success <> 1 BEGIN EXEC sp_OAGetProperty @mime, 'LastErrorText', @sTmp0 OUT PRINT @sTmp0 RETURN END DECLARE @certStore int EXEC @hr = sp_OACreate 'Chilkat.CertStore', @certStore OUT IF @hr <> 0 BEGIN PRINT 'Failed to create ActiveX component' RETURN END EXEC sp_OAMethod @certStore, 'LoadPfxFile', @success OUT, 'myPfx.pfx', 'myPfxPassword' IF @success <> 1 BEGIN EXEC sp_OAGetProperty @certStore, 'LastErrorText', @sTmp0 OUT PRINT @sTmp0 RETURN END -- Find the certificate by email address. There are many -- ways to find certificates within a Chilkat certificate store -- object... DECLARE @cert int EXEC sp_OAMethod @certStore, 'FindCertBySubjectE', @cert OUT, 'support@chilkatsoft.com' IF @cert Is NULL BEGIN EXEC sp_OAGetProperty @certStore, 'LastErrorText', @sTmp0 OUT PRINT @sTmp0 RETURN END DECLARE @privKey int EXEC sp_OAMethod @cert, 'ExportPrivateKey', @privKey OUT IF @privKey Is NULL BEGIN EXEC sp_OAGetProperty @cert, 'LastErrorText', @sTmp0 OUT PRINT @sTmp0 RETURN END EXEC sp_OAMethod @mime, 'Decrypt2', @success OUT, @cert, @privKey IF @success <> 1 BEGIN EXEC sp_OAGetProperty @mime, 'LastErrorText', @sTmp0 OUT PRINT @sTmp0 RETURN END -- Show the decrypted MIME: EXEC sp_OAMethod @mime, 'GetMime', @sTmp0 OUT PRINT @sTmp0 END GO |
© 2000-2010 Chilkat Software, Inc. All Rights Reserved.