Tools, FAQ, Tutorials:
Create Identity Wallet for Isabella
How to Create Identity Wallet for Isabella at MagnetoCorp?
✍: FYIcenter.com
Once Isabella gets a copy of the private key and the certificate
that represents her identity, User1@org1.example.com, on the PaperNet,
she needs to put them in a local wallet.
Whenever Isabella runs an application, it will open the wallet and use her identify to initialize the connection gateway.
1. View the addToWallet.js script that copies private key and certificate into wallet:
(isabella)$ cd ~/hyperledger-binaries/fabric-samples
(isabella)$ cd commercial-paper/organization/magnetocorp/application
(isabella)$ addToWallet.js
/* SPDX-License-Identifier: Apache-2.0
*/
'use strict';
// Bring key classes into scope, most importantly Fabric SDK network class
const fs = require('fs');
const { FileSystemWallet, X509WalletMixin } = require('fabric-network');
const path = require('path');
const fixtures = path.resolve(__dirname, '../../../../basic-network');
// A wallet stores a collection of identities
const wallet = new FileSystemWallet('../identity/user/isabella/wallet');
async function main() {
// Main try/catch block
try {
// Identity to credentials to be stored in the wallet
const credPath = path.join(fixtures, '/crypto-config/peerOrganizations/org1.example.com/users/User1@org1.example.com');
const cert = fs.readFileSync(path.join(credPath, '/msp/signcerts/User1@org1.example.com-cert.pem')).toString();
const key = fs.readFileSync(path.join(credPath, '/msp/keystore/c75bd6911aca808941c3557ee7c97e90f3952e379497dc55eb903f31b50abc83_sk')).toString();
// Load credentials into wallet
const identityLabel = 'User1@org1.example.com';
const identity = X509WalletMixin.createIdentity('Org1MSP', cert, key);
await wallet.import(identityLabel, identity);
} catch (error) {
console.log(`Error adding to wallet. ${error}`);
console.log(error.stack);
}
}
main().then(() => {
console.log('done');
}).catch((e) => {
console.log(e);
console.log(e.stack);
process.exit(-1);
});
2. Run the addToWallet.js script:
(isabella)$ node addToWallet.js done
3. Verify wallet:
(isabella)$ ls ../identity/user/isabella/wallet/User1@org1.example.com User1@org1.example.com c75bd6911aca808941c3557ee7c97e90f3952e379497dc55eb903f31b50abc83-priv c75bd6911aca808941c3557ee7c97e90f3952e379497dc55eb903f31b50abc83-pub
⇒ issue.js - Application to Issue New Paper
⇐ Prepare User Identity for Isabella
2019-11-21, ∼1721🔥, 0💬
Popular Posts:
Where to get a JSON.stringify() Example Code in JavaScript? Here is a good JSON.stringify() example ...
How to access Query String parameters from "context.Request.Url.Que ry"object in Azure API Policy? Q...
How to install "C++/CLI Support" component in Visual Studio? I need to build my Visual Studio C++/CL...
How to use "{{...}}" Liquid Codes in "set-body" Policy Statement? The "{{...}}" Liquid Codes in "set...
How to add request query string Parameters to my Azure API operation to make it more user friendly? ...