Skip to content

Commit

Permalink
[FAB-6706] NodeSDK - handle null verify property
Browse files Browse the repository at this point in the history
NodeSDK should be able to handle a null value for
the verify property since it is optional on a
connection profile configuration file. The default
will be true.

Change-Id: I47fbc07170b88f736dc97ea6c82c27179a914a34
Signed-off-by: Bret Harrison <beharrison@nc.rr.com>
  • Loading branch information
harrisob committed Oct 26, 2017
1 parent 3f5b90a commit 0fca3f5
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 3 deletions.
2 changes: 1 addition & 1 deletion fabric-client/lib/CertificateAuthority.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ var CertificateAuthority = class {
}
this._url = url;
this._connection_options = connection_options;
this._tlsCACerts = tlsCACerts;;
this._tlsCACerts = tlsCACerts;
this._registrar = registrar;
}

Expand Down
15 changes: 13 additions & 2 deletions fabric-client/lib/Client.js
Original file line number Diff line number Diff line change
Expand Up @@ -368,9 +368,20 @@ var Client = class extends BaseClient {
let cas = organization_config.getCertificateAuthorities();
if(cas.length > 0) {
let ca = cas[0];
let tlsCACerts = ca.getTlsCACerts();
if(tlsCACerts) {
tlsCACerts = [tlsCACerts];
} else {
tlsCACerts = [];
}
let connection_options = ca.getConnectionOptions();
let verify = true; //default if not found
if(connection_options && typeof connection_options.verify === 'boolean') {
verify = connection_options.verify
}
tls_options = {
trustedRoots: [ca.getTlsCACerts()], //TODO handle non existent
verify: ca.getConnectionOptions().verify //TODO handle non existent
trustedRoots: tlsCACerts,
verify: verify
};
ca_url = ca.getUrl();
ca_name = ca.getCaName();
Expand Down
4 changes: 4 additions & 0 deletions test/unit/network-config.js
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,10 @@ test('\n\n ** configuration testing **\n\n', function (t) {
let eventHub = client._network_config.getEventHub('peer0.org1.example.com');
t.equals(eventHub._ep._options['request-timeout'],3000, ' check that we get this eventHub timeout set');

delete client._network_config._network_config.certificateAuthorities['ca-org1'].tlsCACerts;
delete client._network_config._network_config.certificateAuthorities['ca-org1'].httpOptions;
let certificate_authority = client.getCertificateAuthority();

},
null,
'2 Should be able to run a number of test without error'
Expand Down

0 comments on commit 0fca3f5

Please sign in to comment.