Skip to content
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
Original file line number Diff line number Diff line change
Expand Up @@ -329,11 +329,18 @@
await this.checkPeerMappings(this.props.peer);
}
// Find the channel members
let mspId = "";
try {

if (this.props.peer) {
const peerDetails = await PeerRestApi.getPeerDetails(this.props.peer[0].id, true);
mspId = peerDetails.msp_id;

Check warning on line 337 in packages/apollo/src/components/JoinChannelModal/JoinChannelModal.js

View workflow job for this annotation

GitHub Actions / Lint

Multiple spaces found before '='
}
let options = {
ordererId: selectedOrderer.node_id,
channelId: selectedChannel,
configtxlator_url: this.props.configtxlator_url
configtxlator_url: this.props.configtxlator_url,
requestingMspId: mspId,
};
let config = await OrdererRestApi.getChannelConfig(options);
let memberIds = this.props.existingMembers.map(x => x.id);
Expand All @@ -359,6 +366,9 @@
} catch (error) {
this.props.updateState(SCOPE, { loading: false });
Log.error('An error occurred when filtering peer list', error);
if(error.code && error.code === "no_certs_available") {

Check warning on line 369 in packages/apollo/src/components/JoinChannelModal/JoinChannelModal.js

View workflow job for this annotation

GitHub Actions / Lint

Expected space(s) after "if"
return;
}
return Promise.reject({
title: error.code || 'error_join_channel_not_found',
details: error,
Expand Down
18 changes: 18 additions & 0 deletions packages/apollo/src/rest/OrdererRestApi.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@
import ChannelApi from './ChannelApi';
import { NodeRestApi } from './NodeRestApi';
import { RestApi } from './RestApi';
import { MspRestApi } from './MspRestApi';
import IdentityApi from './IdentityApi';

const bytes = require('bytes');
const org_template = require('../utils/configtx/org_template.json');
const urlParser = require('url');
Expand Down Expand Up @@ -585,6 +588,18 @@
cert: ordererCerts ? ordererCerts.cert : null,
private_key: ordererCerts ? ordererCerts.private_key : null,
};
if (!test.cert && !test.private_key && options.requestingMspId) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was able to verify the fix locally and it works as expected. I’m digging into the code to better understand it, and I had a quick question about this block.

From my testing, options.requestingMspId is always empty, so this block never runs. I also tested the fix without this block, and it still works as expected by throwing the appropriate exceptions. I was curious, if there a specific scenario where this block would be triggered, or is it intended for other use cases?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi , yes requestingMspId is used but when the join is triggered from the peer page. This is when we know exactly the peer that we are joining to the channel and its MSPID. Hence we can use the admin user of the peer to fetch the channel block. The difference when we don't have a peer is that in such case we cannot determine the MSP admin user to use and therefore, we cannot really filter the channels in case we don't have the admin user of the ordering service.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi, I might not fully understand the context, could you provide an example of when this scenario would occur?

When I tested in the Org2 Console (which includes Org1's Ordering Services) with a valid Associate identity, the cert, private_key, and requestingMSP were all present.
Screenshot 2025-04-25 at 3 56 04 PM

However, after I removed the associate identity from the ordering service, the cert and private_key were set to null, which is expected, but requestingMSP was not populated. Instead, an identityInfo object was created.
Screenshot 2025-04-28 at 3 18 49 PM

I'm trying to understand when a case would arise that satisfies the if-statement you mentioned.

//read the certs/key of the MSP admin identity
const requestingMsp = await MspRestApi.getMSPDetails(options.requestingMspId);
Log.info("Requesting MSP: ", requestingMsp);
let mspIdentities = await IdentityApi.getIdentitiesForMsp(requestingMsp);
let mspAdminIdentities = mspIdentities.filter( (identity) => requestingMsp.admins.includes(identity.cert));

Check warning on line 596 in packages/apollo/src/rest/OrdererRestApi.js

View workflow job for this annotation

GitHub Actions / Lint

There should be no space after this paren
if (mspAdminIdentities.length > 1) {
test.msp_id = options.requestingMspId;
test.cert = mspAdminIdentities[0].cert;
test.private_key = mspAdminIdentities[0].private_key;
}
}
const opts = {
msp_id: test.msp_id,
client_cert_b64pem: test.cert,
Expand All @@ -596,6 +611,9 @@
};
let resp;
try {
if (!opts.client_cert_b64pem || !opts.client_prv_key_b64pem) {
throw { code: 'no_certs_available' };
}
let getChannelConfigBlockFromOrderer;
if (options.genesis) {
getChannelConfigBlockFromOrderer = promisify(window.stitch.getChannelsGenesisFromOrderer);
Expand Down
Loading