Visual Basic Examples

ChilkatHOMEAndroid™ASPVisual BasicVB.NETC#iOS (IPhone)Objective-CC++CMFCDelphiFoxProJavaPerl
PHP ExtensionPHP ActiveXPythonPowerShellRubySQL ServerVBScript

VB Examples

Bounced Mail
Bz2
Character Encoding
CSV
Digital Certificates
Digital Signatures
Email
FTP
HTML Conversion
HTTP
IMAP
Encryption
MHT / HTML Email
POP3
RSA
S/MIME
SFTP
SMTP
Socket
Spider
SSH
SSH Key
SSH Tunnel
String
Tar
Upload
XML
XMP
Zip Compression

More Examples...
Amazon S3
Email Object
DKIM / DomainKey
NTLM
DH Key Exchange
DSA
FileAccess
RSS
Atom
Self-Extractor
Service
Bzip2
PPMD
Deflate
LZW


VB Strings
VB Byte Array

 

 

 

 

 

 

 

Verify S/MIME Signed Message

Download Chilkat MIME ActiveX

This Visual Basic sample program shows how to unwrap the security envelopes in an S/MIME message and verify all signatures present. It can handle both detached signatures (x-pkcs7-signature MIME content-type) or opaque signed-data messages (x-pkcs7-mime content type). The process of verifying the S/MIME signature restores the MIME to its original unsigned state, which makes it easy to access the contents of the message.

' Loads a signed message, unwraps the security envelopes, and determines
' if the signature is valid.  The signed MIME message can be an opaque
' signed-data message, or it can be one with a detached PKCS7 signature.
Private Sub Command1_Click()

        Dim mime As New ChilkatMime


        mime.UnlockComponent "Anything for 30-day trial"
        mime.LoadMimeFile "signed.txt"

        ' Determine if this is a signed message or not.
        If (mime.IsSigned() = 1) Then
            ListBox1.AddItem "Message is signed"
        Else
            ListBox1.AddItem "Message is not signed"
        End If

        ' Unwrap the security.  This is the signature validation.
        ' The results are stored within the Mime object and can be queried
        ' afterwards.
        Dim signatureValid As Long
        signatureValid = mime.UnwrapSecurity()
        If (signatureValid = 1) Then
            ListBox1.AddItem "Signed message has been validated"
        Else
            ListBox1.AddItem "Signed message not validated"
        End If

        ' Get the first signing certificate.
        Dim cert As ChilkatCert
        Set cert = mime.GetSignerCert(0)
        ListBox1.AddItem "Signed By: " + cert.SubjectDN

        ' How many signatures are there?
        ListBox1.AddItem "Num Signatures: " + Str(mime.NumSignerCerts)

        ' This example uses a MIME message that included a GIF attachment.
        ' Save the GIF to a file.
        Dim gifAttachment As ChilkatMime
        Set gifAttachment = mime.GetPart(1)
        gifAttachment.SaveBody "dude.gif"

        ' Save the unwrapped (and now unsigned) MIME messages
        ' in both XML and MIME formats.
        mime.SaveXml "unsigned.xml"
        mime.SaveMime "unsigned.txt"

End Sub






 

© 2000-2012 Chilkat Software, Inc. All Rights Reserved.