SMIME Object

The SMIME object is used for the e-mails securing according to the S/MIME standard. It supports such features as digital signing of the new e-mails, verification of the digital signatures, e-mails encryption and decryption, etc.

Syntax

SMIME.property|method

 

Properties
AlgorithmEncryption Gets or sets the name of the message encryption algorithm.
AlgorithmSigning Gets or sets the name of message signing algorithm.
CSP Gets or sets the name of Cryptographic Service Provider.
Encrypted Indicates if the message is encrypted.
Licensed Indicates if the SMIME object can be used (the valid LicenseKey value has been assigned and the trial period is not yet expired, or the registered version is used).
LicenseKey Sets the license key for the instance of MailBee.SMIME object.
Message Gets or sets the Message object which is processed by the SMIME object.
SenderCert Gets the CertInfo object which contains the information about the certificate of the message sender.
Signed Indicates if the message has a digital signature.
SignerCert Gets the CertInfo object which contains the information about the certificate of the message signer.
SMIMEError Gets the code of the last occurred SMIME error.
SMIMESpecificError Gets the code of the last occurred SMIME-specific error which was returned by Windows API.
Verified Indicates if the authenticity of the message signer was verified successfully and the message was not altered during transmission.
Methods
AddRecipientCert Adds the certificate having the specified parameters to the list of certificates which are used for subsequent encryption of the message.
AddSignerToStore Extracts the certificate of the entity which signed the message, and then places it into the storage which was specified earlier using the SelectSignerCertStore method.
Decrypt Decrypts the encrypted message.
DecryptAndVerify Decrypts the encrypted message and verifies it.
Encrypt Encrypts the message with the public keys contained in the recipient's certificates which were selected earlier using the AddRecipientCert method.
Reset Resets the SMIME object to its default state.
SelectSenderCert Specifies the certificate to be used to sign a new message.
SelectSignerCertStore Specifies the certificate storage where to save the certificate of the entity which signed the message being currently processed.
Sign Adds the digital signature to the message.
SignAndEncrypt Signs the message using the private key contained in the sender's certificate and encrypts this message using the public key contained in the recipient's certificate.
Verify Verifies the authenticity of the message signer and examines the message integrity.

 

Remarks

The developer can reuse a single instance of SMIME object to process multiple messages. Just use the Reset method before processing the next message.

NOTE: Windows 2000 Pro may show certificate selection dialog in some scenarios of using private keys. This may cause problems in server environments when no user interaction with the system is expected (such as ASP). Windows 2000 Server, Windows XP, and Windows 2003 server do not have this problem.

[Visual Basic]

Set objMessage = CreateObject("MailBee.SMIME")

[ASP]
Set objMessage = Server.CreateObject("MailBee.SMIME")

 

Example

The following example demonstrates how the message can be downloaded from file, signed with public recipient's certificate, encrypted with its private certificate (obtained from the system storage) and saved to file. The message could be received from any other source (such as POP3 or IMAP4 object).

[Visual Basic]

Dim objMsg, objSMIME

' Create the new Message object
Set objMsg = CreateObject("MailBee.Message")

' Create the new SMIME object
Set objSMIME = CreateObject("MailBee.SMIME")

' Specify MailBee license key
objSMIME.LicenseKey = "put your license key here"

' Load the message from file
objMsg.ImportFromFile "mail_src.eml"

' Specify the message for the further encryption and signing
Set objSMIME.Message = objMsg

' Add the recipient's certificate for the message encryption
objSMIME.AddRecipientCert "AddressBook", 0, "", "", "", objMsg.PureToAddr

' Select the sender's certificate for the message signing
objSMIME.SelectSenderCert "MY", 0, "", "", "", objMsg.PureFromAddr, ""

' Sign and encrypt the message
objSMIME.SignAndEncrypt

' Check if any errors occurred
If (objSMIME.SMIMEError <> 0) Or (objSMIME.SMIMESpecificError <> 0) Then
    ' Display the code of the last occurred error
    MsgBox "SMIMEError = " & objSMIME.SMIMEError & "   SMIMESpecificError = " & _
      objSMIME.SMIMESpecificError
End If

' Get the signed and encrypted message from the SMIME object
Set objMsg = objSMIME.Message

' Save the message to disk
objMsg.SaveMessage "mail_dst.eml"

 

[ASP]
<%
Dim objMsg, objSMIME

' Create the new Message object
Set objMsg = Server.CreateObject("MailBee.Message")

' Create the new SMIME object
Set objSMIME = Server.CreateObject("MailBee.SMIME")

' Specify MailBee license key
objSMIME.LicenseKey = "put your license key here"

' Load the message from file
objMsg.ImportFromFile "mail_src.eml"

' Specify the message for the further encryption and signing
Set objSMIME.Message = objMsg

' Add the recipient's certificate for the message encryption
objSMIME.AddRecipientCert "AddressBook", 0, "", "", "", objMsg.PureToAddr

' Select the sender's certificate for the message signing
objSMIME.SelectSenderCert "MY", 0, "", "", "", objMsg.PureFromAddr, ""

' Sign and encrypt the message
objSMIME.SignAndEncrypt

' Check if any errors occurred
If (objSMIME.SMIMEError <> 0) Or (objSMIME.SMIMESpecificError <> 0) Then
    ' Display the code of the last occurred error
    Response.Write "SMIMEError = " & objSMIME.SMIMEError & "   SMIMESpecificError = " & _
      objSMIME.SMIMESpecificError
End If

' Get the signed and encrypted message from the SMIME object
Set objMsg = objSMIME.Message

' Save еру message to disk
objMsg.SaveMessage "mail_dst.eml"
%>

 

See Also

Message Object, CertInfo Object

 


Send feedback to AfterLogic
Copyright © 2002-2024, AfterLogic Corporation. All rights reserved.