Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

enable client tls #222

Open
wants to merge 1 commit into
base: v5.0
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
"cors": "2.8.*",
"express": "4.14.*",
"express-session": "1.14.*",
"fabric-ca-client": "1.0.5",
"fabric-client": "1.0.5",
"fabric-ca-client": "1.1.0",
"fabric-client": "1.1.0",
"pug": "2.0.0-beta11",
"serve-static": "1.11.*",
"winston": "2.2.*",
Expand Down
21 changes: 21 additions & 0 deletions utils/connection_profile_lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,27 @@ module.exports = function (config_filename, logger) {
return ret;
};

cp.getClientTLSCerts = function (msp_id) {
var clientKey = '';
var clientCert = '';
var path2cert = path.join(__dirname, '../../config/crypto/' + msp_id);
try {
if (fs.lstatSync(path2cert).isDirectory()) {
var keystorePath = path2cert + '/keystore/';
var signCertsPath = path2cert + '/signcerts/cert.pem';
if (fs.lstatSync(keystorePath).isDirectory()) {
const priv_cert = fs.readdirSync(keystorePath);
clientKey = fs.readFileSync(keystorePath+priv_cert[0], 'utf8') + '\r\n';
clientCert = fs.readFileSync(signCertsPath, 'utf8') + '\r\n';
}
}
} catch(e) {
console.log('Could not find Client TLS folder for ', msp_id, ' not using Client TLS');
return null;
}
return {clientKey, clientCert};
};

// get the very first channel name from creds
cp.getFirstChannelId = function () {
if (cp.creds && cp.creds.channels) {
Expand Down
9 changes: 8 additions & 1 deletion utils/connection_profile_lib/parts/orderer.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,14 @@ module.exports = function (cp, logger) {
throw new Error('Orderer\'s key not passed');
} else {
let orderer = helper.getOrderer(key);
return cp.buildTlsOpts(orderer);
var orderer_opts = cp.buildTlsOpts(orderer);
var org = cp.getClientOrg();
var client_tls = cp.getClientTLSCerts(org);
if (client_tls) {
orderer_opts.clientKey = client_tls.clientKey;
orderer_opts.clientCert = client_tls.clientCert;
}
return orderer_opts;
}
};

Expand Down
9 changes: 8 additions & 1 deletion utils/connection_profile_lib/parts/peer.js
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,14 @@ module.exports = function (cp, logger) {
throw new Error('Peer\'s key not passed');
} else {
let peer = helper.getPeer(key);
return cp.buildTlsOpts(peer);
var peer_opts = cp.buildTlsOpts(peer);
var org = cp.getClientOrg();
var client_tls = cp.getClientTLSCerts(org);
if (client_tls) {
peer_opts.clientKey = client_tls.clientKey;
peer_opts.clientCert = client_tls.clientCert;
}
return peer_opts;
}
};

Expand Down