Framework EDI Reference. Methods and Properties
ediSecurities. ImportExchangeKeyPair

Imports a file containing the Public/Private key pair into a Cryptographic Service Provider (CSP) key container.

Syntax

<lretval> = object. ImportExchangeKeyPair(<sImportFileName>, <sPassword>, <sNewContainerName>, [<sServiceProvider>], [< lProviderType>])

Parameters

Returns

Returns 1 if the operation is successful; otherwise returns 0 if the operation fails.

Remarks

A new key container specified by sNewContainerName is created before the keys are imported to the new key container. If the key fails to import to the new key container, the new key container will not be deleted. It is left up to the user to delete the key container. The keys imported must belong to the same service provider that exported the keys.

The sServiceProvider and lProviderType specify the CSP database where the key container is imported to.  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 sImportFileName As String
Dim sPassword As String
Dim sKeyContainerName As String
Dim sProviderName As String

sImportFileName = App.Path & "\KeyExchangePair.bin"
sPassword = "Quick brown fox"
sKeyContainerName = "FREDITEST_RECIPIENT2"
sProviderName = "Microsoft Base Cryptographic Provider v1.0"

Set oEdiDoc = New Fredi.ediDocument
Set oSecurities = oEdiDoc.GetSecurities

oSecurities.ImportExchangeKeyPair sImportFileName, sPassword, sKeyContainerName, sProviderName

Sample

M_ImportExchangeKeyPair.zip