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. |
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:
brokerCaBundle :String
The bundle containing the broker CA certificates in PEM format.
Type:
- String
brokers :Array.<Broker>
An array of Broker objects representing brokers comprising the DXL fabric. This could be webSockets brokers depending on configuration
Type:
- Array.<Broker>
cert :String
The client certificate in PEM format.
Type:
- String
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
privateKey :String
The client private key in PEM format.
Type:
- String
reconnectDelay :Number
The delay between retry attempts in seconds.
Type:
- Number
useWebSockets :String
Flag to use websocketBrokers if defined in the config
Type:
- String
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 |
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 theoptions
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
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
options |
Object |
<optional> |
Additional options for the provision operation. Properties
|