Framework EDI Reference. Methods and Properties
ediSecurities. CreateTestCertificate

Creates an X.509 test certificate.

Syntax

<lretval> = object. CreateTestCertificate(<sTestCertificateFile>,<sSubjectName>, <sIssuerName>, <sKeyContainerName>, <KeyPairType>, [<sServiceProvider>], [< lProviderType>])

Parameters

Returns

Returns 1 if the certificate is created successfully; otherwise returns 0 if the operation fails.

Remarks

This method creates a certificate from the key container specified.  The public key of the key container is stored in the certificate and the CSP information -- service provider name, service provider type, key container name and the key pair type -- is stored in the certificate to associate the certificate to the key container.  This allows this certificate to perform operations that require the private key.

The sServiceProvider and lProviderType specify the CSP that has the key container.  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.

Note that the certificate created does not get imported to the certificate store.  It must be imported into the certificate store using the ImportCertificate before it can be used.

 

 

Example:

Dim oEdiDoc As Fredi.ediDocument
Dim oSecurities As Fredi.ediSecurities

' 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"

'' To specify valid dates for the certificate, uncomment lines below.
' oSecurities.Property(CertStoreProperty_ValidFrom) = "08/01/2006"
' oSecurities.Property(CertStoreProperty_ValidTo) = "08/05/2006"

' Create test certificate.
If oSecurities.CreateTestCertificate(App.Path & "\MyCertificate.cer", "Test Certificate", "Test Certificate", "FrameworkEDI_Secure_Context_00", CspKeyType_KEYEXCHANGE) = 1 Then
MsgBox "Certificate created"

Else
MsgBox "Failed to create certificate"

End If

Sample

M_CreateTestCertificate.zip