mirror of
https://github.com/hyperledger/fabric-samples.git
synced 2026-06-25 11:05:10 +00:00
hsm script changes
Readme changes Added npm prepare Signed-off-by: sapthasurendran <saptha.surendran@ibm.com>
This commit is contained in:
parent
2f73b19056
commit
217c510979
4 changed files with 28 additions and 20 deletions
|
|
@ -82,15 +82,17 @@ To be able to register and enroll identities using an HSM you need a PKCS#11 ena
|
||||||
To install this use the following command
|
To install this use the following command
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
go get -tags 'pkcs11' github.com/hyperledger/fabric-ca/cmd/fabric-ca-client
|
go install -tags 'pkcs11' github.com/hyperledger/fabric-ca/cmd/fabric-ca-client@latest
|
||||||
```
|
```
|
||||||
## Enroll the HSM User
|
## Enroll the HSM User
|
||||||
|
|
||||||
A user, `HSMUser`, who is HSM managed needs to be registered then enrolled for the sample
|
A user, `HSMUser`, who is HSM managed needs to be registered then enrolled for the sample.
|
||||||
|
|
||||||
|
If the "standard" PKCS11 library locations checked for by the script don't include the library(libsofthsm2.so) location for your environment set the `PKCS11_LIB` environment variable to define the library location.
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
cd scripts
|
cd scripts
|
||||||
./generate-hsm-user.sh HSMUser
|
PKCS11_LIB='<path to PKCS11 library location>' ./generate-hsm-user.sh HSMUser
|
||||||
```
|
```
|
||||||
|
|
||||||
This will register a user `HSMUser` with the CA in Org1 (if not already registered) and then enroll that user which will
|
This will register a user `HSMUser` with the CA in Org1 (if not already registered) and then enroll that user which will
|
||||||
|
|
@ -110,7 +112,6 @@ go run -tags pkcs11 hsm-sample.go
|
||||||
```
|
```
|
||||||
cd application-gateway-hsm/node
|
cd application-gateway-hsm/node
|
||||||
npm install
|
npm install
|
||||||
npm run build
|
|
||||||
npm start
|
npm start
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -7,6 +7,7 @@
|
||||||
"node": "^14.15.0 || ^16.13.0"
|
"node": "^14.15.0 || ^16.13.0"
|
||||||
},
|
},
|
||||||
"scripts": {
|
"scripts": {
|
||||||
|
"prepare": "npm run build",
|
||||||
"build": "npm-run-all clean compile lint",
|
"build": "npm-run-all clean compile lint",
|
||||||
"clean": "rimraf dist",
|
"clean": "rimraf dist",
|
||||||
"compile": "tsc",
|
"compile": "tsc",
|
||||||
|
|
|
||||||
|
|
@ -6,19 +6,27 @@ CA_HOST=localhost
|
||||||
CA_URL=${CA_HOST}:7054
|
CA_URL=${CA_HOST}:7054
|
||||||
TLS_CERT='../../../test-network/organizations/fabric-ca/org1/tls-cert.pem'
|
TLS_CERT='../../../test-network/organizations/fabric-ca/org1/tls-cert.pem'
|
||||||
|
|
||||||
# try to locate the Soft HSM library
|
LocateHsmLib() {
|
||||||
POSSIBLE_LIB_LOC=('/usr/lib/softhsm/libsofthsm2.so' \
|
if [[ -n "${PKCS11_LIB}" && -f "${PKCS11_LIB}" ]]; then
|
||||||
'/usr/lib/x86_64-linux-gnu/softhsm/libsofthsm2.so' \
|
echo "${PKCS11_LIB}"
|
||||||
'/usr/local/lib/softhsm/libsofthsm2.so' \
|
return
|
||||||
'/usr/lib/libacsp-pkcs11.so'
|
|
||||||
)
|
|
||||||
for TEST_LIB in "${POSSIBLE_LIB_LOC[@]}"
|
|
||||||
do
|
|
||||||
if [ -f $TEST_LIB ]; then
|
|
||||||
HSM2_LIB=$TEST_LIB
|
|
||||||
break
|
|
||||||
fi
|
fi
|
||||||
done
|
|
||||||
|
local POSSIBLE_LIB_LOC=( \
|
||||||
|
'/usr/lib/softhsm/libsofthsm2.so' \
|
||||||
|
'/usr/lib/x86_64-linux-gnu/softhsm/libsofthsm2.so' \
|
||||||
|
'/usr/local/lib/softhsm/libsofthsm2.so' \
|
||||||
|
'/usr/lib/libacsp-pkcs11.so' \
|
||||||
|
)
|
||||||
|
for TEST_LIB in "${POSSIBLE_LIB_LOC[@]}"; do
|
||||||
|
if [ -f "${TEST_LIB}" ]; then
|
||||||
|
echo "${TEST_LIB}"
|
||||||
|
return
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
}
|
||||||
|
|
||||||
|
HSM2_LIB=$(LocateHsmLib)
|
||||||
[ -z $HSM2_LIB ] && echo No SoftHSM PKCS11 Library found, ensure you have installed softhsm2 && exit 1
|
[ -z $HSM2_LIB ] && echo No SoftHSM PKCS11 Library found, ensure you have installed softhsm2 && exit 1
|
||||||
|
|
||||||
# create a softhsm2.conf file if one doesn't exist
|
# create a softhsm2.conf file if one doesn't exist
|
||||||
|
|
|
||||||
|
|
@ -113,10 +113,8 @@ pushd ../asset-transfer-basic/application-gateway-hsm/scripts/
|
||||||
print "Enroll and register User in HSM"
|
print "Enroll and register User in HSM"
|
||||||
./generate-hsm-user.sh HSMUser
|
./generate-hsm-user.sh HSMUser
|
||||||
pushd ../node/
|
pushd ../node/
|
||||||
print "install dependencies"
|
print "install dependencies and prepare for running"
|
||||||
npm install
|
npm install
|
||||||
print "Building hsm-sample.ts"
|
|
||||||
npm run build
|
|
||||||
print "Running the output app"
|
print "Running the output app"
|
||||||
npm run start
|
npm run start
|
||||||
popd
|
popd
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue