Gets the certificate object of an X.509 certificate from the certificate store.
Syntax:
Set <oCertificate> = object. GetCertificate(<sSubjectName>, <sIssuerName>, <sHexSerialNumber>, [<sServiceProvider>], [<lProviderType>])
Parameters:
Returns
Returns an object of type FREDI.ediSecurityCertificate if the certificate is found; otherwise NULL or an empty object is returned.
Remarks
The sSubjectName, sIssuerName and sHexSerialNumber are used to search for the certificate in the certificate store. See Locating a Digital Certificate.
The sServiceProvider and lProviderType specify the CSP used for security services. All security done by the certificate store will be handled by the CSP. If sServiceProvider and/or lProviderType are not specified, the default CSP database is used, which is specified by DefaultProviderName andServiceProviderType. The type of database, whether machine key set or user key set, is specified using ediDocument.Option by the constant OptDocument_MachineKeySet.
Example:
Dim oEdiDoc As Fredi.ediDocument
Dim oSecurities As Fredi.ediSecurities
Dim oCertificate As Fredi.ediSecurityCertificate
' Create instance of Framework EDI.
Set oEdiDoc = New Fredi.ediDocument
' Get securities object.
Set oSecurities = oEdiDoc.GetSecurities
' Set the default certificate store
oSecurities.DefaultCertSystemStoreName = "My" ' Case sensitive
' Set the default certificate store location
oSecurities.DefaultCertSystemStoreLocation = "CurrentUser"
Set oCertificate = oSecurities.GetCertificate("Administrator", "", "")
If oCertificate Is Nothing Then
MsgBox "Certificate not found"Else
Dim sSubjectName As StringEnd If
Dim sIssuerName As String
Dim sHexSerialNumber As String
Dim sFoundMsg As String
sSubjectName = oCertificate.SubjectName
sIssuerName = oCertificate.IssuerName
sHexSerialNumber = oCertificate.SerialNumber
sFoundMsg = "Certificate found. " & vbCrLf & vbCrLf
sFoundMsg = sFoundMsg & "Subject Name: " & sSubjectName & vbCrLf
sFoundMsg = sFoundMsg & "Issuer Name: " & sIssuerName & vbCrLf
sFoundMsg = sFoundMsg & "Serial Number: " & sHexSerialNumber & vbCrLf
MsgBox sFoundMsg
Sample