Class: Config

Config(brokerCaBundle, cert, privateKey, brokers, webSocketBrokers, useWebSockets, proxy)

new Config(brokerCaBundle, cert, privateKey, brokers, webSocketBrokers, useWebSockets, proxy)

The Data Exchange Layer (DXL) client configuration contains the information necessary to connect a Client to the DXL fabric.

The configuration includes the required PKI information (client certificate, client private key, broker CA certificates) and the set of DXL message brokers that are available to connect to on the fabric.

Parameters:
Name Type Description
brokerCaBundle String

The bundle containing the broker CA certificates in PEM format.

cert String

The client certificate in PEM format.

privateKey String

The client private key in PEM format.

brokers Array.<Broker>

An array of Broker objects representing brokers comprising the DXL fabric.

webSocketBrokers Array.<Broker>

An array of Broker objects representing brokers on the DXL fabric supporting DXL connections over WebSockets.

useWebSockets Boolean

If true and webSocketBrokers are defined, client will attempt to connect over WebSockets.

proxy proxy

Information- If non null the proxy settings will be used. This is for WebSocket connections only.

Source:
Example
var dxl = require('@opendxl/dxl-client')
var fs = require('fs')
var config = new dxl.Config(
  fs.readFileSync('c:\\certs\\brokercerts.crt'),
  fs.readFileSync('c:\\certs\\client.crt'),
  fs.readFileSync('c:\\certs\\client.key'),
  [dxl.Broker.parse('ssl://192.168.99.100')])

var client = new dxl.Client(config)
client.connect()

Members

_proxy :Proxy

The proxy information for the Connection via WebSockets only

Type:
Source:

brokerCaBundle :String

The bundle containing the broker CA certificates in PEM format.

Type:
  • String
Source:

brokers :Array.<Broker>

An array of Broker objects representing brokers comprising the DXL fabric. This could be webSockets brokers depending on configuration

Type:
Source:

cert :String

The client certificate in PEM format.

Type:
  • String
Source:

keepAliveInterval :number

The maximum period in seconds between communications with a connected Broker. If no other messages are being exchanged, this controls the rate at which the client will send ping messages to the Broker.

Type:
  • number
Default Value:
  • 1800
Source:

privateKey :String

The client private key in PEM format.

Type:
  • String
Source:

reconnectDelay :Number

The delay between retry attempts in seconds.

Type:
  • Number
Default Value:
  • 1
Source:

useWebSockets :String

Flag to use websocketBrokers if defined in the config

Type:
  • String
Source:

Methods

(static) createDxlConfigFromFile(configFile) → {Config}

This method allows creation of a Config object from a specified configuration file. The information contained in the file has a one-to-one correspondence with the Config constructor.

[Certs]
BrokerCertChain=c:\\\\certs\\\\brokercerts.crt
CertFile=c:\\\\certs\\\\client.crt
PrivateKey=c:\\\\certs\\\\client.key

[Brokers]
mybroker=mybroker;8883;mybroker.mcafee.com;192.168.1.12
mybroker2=mybroker2;8883;mybroker2.mcafee.com;192.168.1.13
Parameters:
Name Type Description
configFile String

Path to the configuration file

Source:
Throws:
  • If an error is encountered when attempting to read the configuration file.

    Type
    DxlError
  • If one or more of the entries in the broker section of the configuration is invalid.

    Type
    MalformedBrokerError
Returns:

A Config object corresponding to the specified configuration file.

Type
Config
Example
var config = dxl.Config.createDxlConfigFromFile(c:\\certs\\dxlclient.config)

(static) provisionConfig(configDir, commonOrCsrFileName, hostInfo, optionsopt)

Provisions a DXL client by performing the following steps:

  • Either generates a certificate signing request and private key, storing each to a file (the default), or reads the certificate signing request from a file (if the certRequestFile property under the options object is present and has a truthy value).

  • Sends the certificate signing request to a signing endpoint on a management server. If the request is successfully authenticated and authorized, the management server is expected to respond with the following data:

    • [ca bundle] - a concatenation of one or more PEM-encoded CA certificates
    • [signed client cert] - a PEM-encoded certificate signed from the certificate request
    • [broker config] - zero or more lines, each delimited by a line feed character, for each of the brokers known to the management service. Each line contains a key and value, delimited by an equal sign. The key contains a broker guid. The value contains other metadata for the broker, e.g., the broker guid, port, hostname, and ip address. For example: "[guid1]=[guid1];8883;broker;10.10.1.1\n[guid2]=[guid2]...".
  • Saves the [ca bundle] and [signed client cert] to separate files.

  • Creates a "dxlclient.config" file with the following sections:

    • A "Certs" section with certificate configuration which refers to the locations of the private key, ca bundle, and certificate files.
    • A "Brokers" section with the content of the [broker config] provided by the management service.
Parameters:
Name Type Attributes Description
configDir String

Directory in which to store the configuration data.

commonOrCsrFileName String

A string representing either a common name (CN) to add into the generated file or the path to the location of an existing CSR file. The parameter is interpreted as a path to an existing CSR file if a property named certRequestFile exists on the command object and has a truthy value. If the parameter represents a path to an existing CSR file, this function does not generate a new CSR file.

hostInfo Object

Info for the management service host.

Properties
Name Type Attributes Default Description
user String

Username to run remote commands as.

password String

Password for the management service user.

port String <optional>
8443

Port at which the management service resides.

truststore String <optional>

Location of a file of CA certificates to use when verifying the management service's certificate. If no value is specified, no validation of the management service's certificate is performed.

options Object <optional>

Additional options for the provision operation.

Properties
Name Type Attributes Default Description
certRequestFile Boolean <optional>

If present and truthy, interprets the commonOrCsrFileName parameter as the name of an existing CSR file.

filePrefix String <optional>
client

Prefix of the private key, CSR, and certificate to store.

opensslbin String <optional>

Path to the openssl executable. If not specified, the function attempts to find the openssl executable from the environment path.

passphrase String <optional>

Password to use for encrypting the private key.

san Array.<String> <optional>

List of subject alternative names to add to the CSR.

country String <optional>

Country (C) to use in the CSR's Subject DN.

stateOrProvince String <optional>

State or province (ST) to use in the CSR's Subject DN.

locality String <optional>

Locality (L) to use in the CSR's Subject DN.

organization String <optional>

Organization (O) to use in the CSR's Subject DN.

organizationalUnit String <optional>

Organizational Unit (OU) to use in the CSR's Subject DN.

emailAddress String <optional>

E-mail address to use in the CSR's Subject DN.

doneCallback function <optional>

Callback to invoke once the provisioned configuration has been stored. If an error occurs, the first parameter supplied to the doneCallback is an Error instance containing failure details.

Source: