DecryptAndVerify Method


Decrypts the encrypted message and verifies its signature if it's present in the message.

You can optionally specify the certificate store where to find the certificate suitable for decryption.


[Visual Basic]

blnResult = ObjectName.DecryptAndVerify([Store], [StoreType], [PfxPassword])

 
Parameters:  
Store As String

(optional) The name of the certificate's storage. The following names are supported for the system storage (REGISTRY_STORE):

  • MY - the personal user's certificates storage
  • AddressBook - other people certificates storage
  • CA - Intermediate Certification Authorities
  • Root - Trusted Root Certification Authorities

When using a file storage (FILE_STORE or FILE_PFX_STORE) this parameter should contain the name of this file storage.

 

The default value is "MY".

 
StoreType As Long

(optional) The type of the certificate's storage. MailBee supports the following types of certificate's storages:

  • REGISTRY_STORE = 0 - the standard system storage which belongs to the current user (not applicable for web applications which are usually run under the special system user, not the interactive user)
  • FILE_STORE = 1 - file storage
  • FILE_PFX_STORE = 2 - password-protected PFX file storage

The default value is 0.

 
PfxPassword As String (optional) The password which should be used to access the certificates storage if it's a PFX file. The default value is an empty string.  
Return value As Boolean True if successful, False if error has occurred.  
Remarks:

Only signed messages can be decrypted and verified. If the message is not encrypted nothing happens.

 

To check if the message was encrypted or verified the developer can use the Encrypted or Verified properties.


Usage example:

' This example loads the encrypted message from file, decrypts and verifies this message.

Dim objSMIME, objMsg

' Using Visual Basic to create the objects
Set objMsg = CreateObject("MailBee.Message")
Set objSMIME = CreateObject("MailBee.SMIME")

' Using ASP to create the objects
'Set objMsg = Server.CreateObject("MailBee.Message")
'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 processing
Set objSMIME.Message = objMsg

' Check if the message is encrypted
If objSMIME.Encrypted Then
	' Decrypt and verify the message
	objSMIME.DecryptAndVerify

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

See Also:

Decrypt Method, Verify Method


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