SelectServerCertStore Method


Selects the store where to search server certificate.

This method is used for testing validity of server certificates. However, this method is required only if you're implementing your own certificate stores.

By default (VerifyServerCert=False), MailBee does not check server certificates. However, if VerifyServerCert=True, MailBee will determine whether the server certificate is trusted during connecting to the server. If the certificate is not trusted, the connection is refused.

MailBee concludes the certificate is trusted if it is signed by well-known authority. Default store of well-known authorities is "ROOT" system store. You can access this store through "Control panel/Internet options/Content/Certificates/Trusted Root Certification Authorities" panel. However, you can always select your own trusted store using SelectServerCertStore method.

Note: This method will make effect only if it called BEFORE connecting to the mail server. Also VerifyServerCert must be True.


blnResult = ObjectName.SelectServerCertStore(Path, StoreType, [Options])  
Parameters:  
Path As String Filename or system registry name of the store. Allowed system registry names are:
  • "MY" - Personal certificates of the user. This is common store of clients certificates but not usually applicable for server certificates
  • "CA" - Intermediate authorities. This is common store of server certificates' issuers
  • "ROOT" - Trusted list of Internet certification authorities. Well-known servers usually have certificates signed by authorities from the "ROOT"
 
StoreType As Long Type of the certificate store to select certificate from. Allowed values are:
  • 0 - System registry. Path must be one of the strings "MY", "CA", "ROOT"
  • 1 - File store. Path must be the valid filename of certificate store
 
Options As Long (optional) By default, server certificate is considered "trusted" by the store if certificate issuer name is found in the store. However, you may override this behavior. If Options is specified, can be any combination of the following values:
  • 1 - Search by certificate name
  • 2 - Search by certificate issuer name. This is default behavior commonly used in secure communications
  • 128 - Server certificate if not found in the store will be automatically added to the store. Thus, any server becomes trusted for this store
 
Return value As Boolean Always True  

Usage example:

Dim Mailer
'Using visual basic to create object
Set Mailer = CreateObject("MailBee.SMTP")
'Using ASP to create object
'Set Mailer = Server.CreateObject("MailBee.SMTP")
'In ASP use Response.Write instead of MsgBox
Mailer.EnableLogging = True
Mailer.LogFilePath = "C:\Temp\smtp_log.txt"
Mailer.ClearLog
Mailer.LicenseKey = "put your license key here"

' Set SSL connection over STARTTLS command
Mailer.SSL.Enabled = True
Mailer.SSL.UseStartTLS = True

' Select system's TRUSTED ROOT as a source of trusted authorities
Mailer.SSL.SelectServerCertStore("ROOT", 0) ' select active certificate

Mailer.SSL.VerifyServerCert = True
Mailer.Connect "mail.server.com", 465 MsgBox Mailer.SSL.ServerCert.IssuedTo ' display info on the certificate owner

See Also:

ServerCert Property


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