Skip to content

Commit

Permalink
EWC-352 self signed cert fixes: (#369)
Browse files Browse the repository at this point in the history
* correct cert reading from file in routes
* correct options for connector's calls with selfi signed cert
  • Loading branch information
mchepelev authored and Railag committed Nov 19, 2018
1 parent 96b45b0 commit 47f427b
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 7 deletions.
9 changes: 4 additions & 5 deletions src/services/connector-service.js
Original file line number Diff line number Diff line change
Expand Up @@ -125,11 +125,6 @@ async function _makeRequest(connector, options, data) {
});
});

if (connector.cert && connector.isSelfSignedCert === true) {
const ca = fs.readFileSync(connector.cert);
options.ca = new Buffer(ca);
}

httpreq.on('error', function (err) {
console.log(err);
if (err instanceof Error)
Expand Down Expand Up @@ -165,6 +160,10 @@ async function openPortsOnConnector(connector, isPublicAccess, transaction) {
'Content-Length': Buffer.byteLength(data)
}
};
if (connector.cert && connector.isSelfSignedCert === true) {
const ca = fs.readFileSync(connector.cert);
options.ca = new Buffer(ca);
}

const ports = await _makeRequest(connector, options, data);
return ports
Expand Down
4 changes: 2 additions & 2 deletions src/services/microservices-service.js
Original file line number Diff line number Diff line change
Expand Up @@ -398,7 +398,7 @@ async function _createRouteOverConnector(sourceMicroservice, destMicroservice, u
const sourceNetwMsConfig = {
'mode': 'private',
'host': connector.domain,
'cert': connector.cert,
'cert': AppHelper.trimCertificate(fs.readFileSync(connector.cert, "utf-8")),
'port': ports.port1,
'passcode': ports.passcode1,
'connectioncount': 1,
Expand All @@ -420,7 +420,7 @@ async function _createRouteOverConnector(sourceMicroservice, destMicroservice, u
const destNetwMsConfig = {
'mode': 'private',
'host': connector.domain,
'cert': connector.cert,
'cert': AppHelper.trimCertificate(fs.readFileSync(connector.cert, "utf-8")),
'port': ports.port2,
'passcode': ports.passcode2,
'connectioncount': 1,
Expand Down

0 comments on commit 47f427b

Please sign in to comment.