Procedure for Creating a Test X.509 Test Certificate |
The steps to creating a test certificate is as follows:
Example in Visual Basic
Create an instance of ediDocument. The ediDocument object is the top level application instance for Framework EDI (FREDI). This object is the topmost object in the object model hierarchy of FREDI. This instance is always created at the start of a program.
Optional. By default, key containers used are only those key containers that are accessible to the logon user. If key containers pertinent to the local machine are used then enter the following statement.Dim oEdiDoc As Fredi.ediDocument
Set oEdiDoc = New Fredi.ediDocument
oEdiDoc.Option(OptDocument_MachineKeySet) = 1
Specify Cryptographic Service Provider to use for security. The ediSecurities object provide the security capabilities in FREDI. This object is accessible directly from ediDocument, and its settings persist for the life of the program. To specify the default Cryptographic Service Provider (CSP) to use, set the DefaultProviderName property. Once set, this CSP persists until it is changed. In this example, we use "Microsoft Base Cryptographic Provider v1.0".
Dim oSecurities As Fredi.ediSecurities
Set oSecurities = oEdiDoc.GetSecurities
' Set the default service provider name in the securities object so that
' we do not have to set it everywhere else.
oSecurities.DefaultProviderName = "Microsoft Base Cryptographic Provider v1.0"
Call CreateTestCertificate method from ediSecurities object. Call the CreateTestCertificate method in the ediSecurities object to create the Test Certificate. Since this is a self-signed certificate, both the subject name and the issuer name are the same. The key container, used to get the public key from and store to the certificate, must already exist. In this example, the public key from the Key Exchange public/private key pair of the key container will be used to store in the certificate. The private key of the key container is used to sign the certificate.
sCertificateFileName = "C:\TEMP\TESTCERTIFICATE.CER"
sSubjectName = "Test ABC Company"
sIssuerName = sSubjectName
sContainerName = "Test ABC Key Container"
oSecurities.CreateTestCertificate sCertificateFileName, sSubjectName, sIssuerName, sContainerName, CspKeyType_KEYEXCHANGE
Example Program
Dim oEdiDoc As Fredi.ediDocument
Dim oSecurities As Fredi.ediSecurities
Dim sCertificateFileName As String
Dim sSubjectName As String
Dim sIssuerName As String
Dim sContainerName As String
Set oEdiDoc = New Fredi.ediDocument
' For local machine key set.
' oEdiDoc.Option(OptDocument_MachineKeySet) = 1
Set oSecurities = oEdiDoc.GetSecurities
' Set the default service provider name in the securities object so that
' we do not have to set it everywhere else.
oSecurities.DefaultProviderName = "Microsoft Base Cryptographic Provider v1.0"
sCertificateFileName = "C:\TEMP\TESTCERTIFICATE.CER"
sSubjectName = "Test ABC Company"
sContainerName = "Test ABC Key Container"' Self-signed certificate, the Issuer name is the same as the Subject name.
sIssuerName = sSubjectNameoSecurities.CreateTestCertificate sCertificateFileName, sSubjectName, sSubjectName, sContainerName, CspKeyType_KEYEXCHANGE