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
|
Unwrap S/MIME Security LayersDemonstrates how to unwrap the security layers of a signed and/or encrypted S/MIME message. LOCAL i LOCAL loMime LOCAL lnSuccess LOCAL loCert LOCAL lnNumSignerCerts LOCAL lnNumEncryptCerts loMime = CreateObject('Chilkat.Mime') lnSuccess = loMime.UnlockComponent("Anything for 30-day trial") IF (lnSuccess = 0) THEN =MESSAGEBOX(loMime.LastErrorText) QUIT ENDIF * Note: Your S/MIME file may have a different file extension. lnSuccess = loMime.LoadMimeFile("smime.eml") IF (lnSuccess = 0) THEN =MESSAGEBOX(loMime.LastErrorText) QUIT ENDIF * Unwrap any security layers so that the resultant MIME * is the original message before signing and/or encrypting * was applied. UnwrapSecurity returns 1 if * there was nothing to unwrap, or if all signatures were verified, * and all decryptions succeeded. lnSuccess = loMime.UnwrapSecurity() IF (lnSuccess = 0) THEN =MESSAGEBOX(loMime.LastErrorText) QUIT ENDIF * Save the unwrapped S/MIME: lnSuccess = loMime.SaveMime("unwrapped.eml") IF (lnSuccess = 0) THEN =MESSAGEBOX(loMime.LastErrorText) QUIT ENDIF * Let's see if the MIME was signed, and if so whether * the signature(s) were verified. Also, examine the certificate * used for signing. * Unwrapping the security sets the NumSignerCerts property. * If it is non-zero, then signatures were unwrapped... ? "Signer Certificates: " lnNumSignerCerts = loMime.NumSignerCerts IF (lnNumSignerCerts > 0) THEN FOR i = 0 TO lnNumSignerCerts - 1 loCert = loMime.GetSignerCert(i) IF (NOT (loCert = NULL )) THEN * Show the cert's common name. ? loCert.SubjectCN ENDIF NEXT ENDIF * Now check to see if anything was decrypted. ? "Encryption Certificates: " lnNumEncryptCerts = loMime.NumEncryptCerts IF (lnNumEncryptCerts > 0) THEN FOR i = 0 TO lnNumEncryptCerts - 1 loCert = loMime.GetEncryptCert(i) IF (NOT (loCert = NULL )) THEN * Show the cert's common name. ? loCert.SubjectCN ENDIF NEXT ENDIF |
© 2000-2010 Chilkat Software, Inc. All Rights Reserved.
Mail Component · .NET Email Component · ASP Mail Component · XML Parser