diff --git a/asset-transfer-basic/application-gateway-hsm/README.md b/asset-transfer-basic/application-gateway-hsm/README.md index 8cbd8155..4b7cdb23 100644 --- a/asset-transfer-basic/application-gateway-hsm/README.md +++ b/asset-transfer-basic/application-gateway-hsm/README.md @@ -65,12 +65,12 @@ Or compiled and installed from source: If you have not initialized a token previously (or it has been deleted) then you will need to perform this one time operation ```bash -echo directories.tokendir = /tmp > ./softhsm2.conf -export SOFTHSM2_CONF=./softhsm2.conf +echo directories.tokendir = /tmp > $HOME/softhsm2.conf +export SOFTHSM2_CONF=$HOME/softhsm2.conf softhsm2-util --init-token --slot 0 --label "ForFabric" --pin 98765432 --so-pin 1234 ``` -This will create a SoftHSM configuration file called `softhsm2.conf` and will be stored in the current directory. This is +This will create a SoftHSM configuration file called `softhsm2.conf` and will be stored in the home directory. This is where the sample expects to find a SoftHSM configuration file The Security Officer PIN, specified with the `--so-pin` flag, can be used to re-initialize the token, diff --git a/asset-transfer-basic/application-gateway-hsm/scripts/generate-hsm-user.sh b/asset-transfer-basic/application-gateway-hsm/scripts/generate-hsm-user.sh index 04ec72e0..481ca22b 100755 --- a/asset-transfer-basic/application-gateway-hsm/scripts/generate-hsm-user.sh +++ b/asset-transfer-basic/application-gateway-hsm/scripts/generate-hsm-user.sh @@ -22,7 +22,7 @@ done [ -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 -HSM2_CONF=../softhsm2.conf +HSM2_CONF=$HOME/softhsm2.conf [ ! -f $HSM2_CONF ] && echo directories.tokendir = /tmp > $HSM2_CONF # Update the client config file to point to the softhsm pkcs11 library diff --git a/asset-transfer-basic/application-gateway-hsm/softhsm2.conf b/asset-transfer-basic/application-gateway-hsm/softhsm2.conf deleted file mode 100644 index 86687cf7..00000000 --- a/asset-transfer-basic/application-gateway-hsm/softhsm2.conf +++ /dev/null @@ -1,5 +0,0 @@ -directories.tokendir = /tmp/ -objectstore.backend = file - -# ERROR, WARNING, INFO, DEBUG -log.level = INFO \ No newline at end of file diff --git a/ci/azure-pipelines.yml b/ci/azure-pipelines.yml index 0776f5f5..95d1db47 100644 --- a/ci/azure-pipelines.yml +++ b/ci/azure-pipelines.yml @@ -21,87 +21,87 @@ variables: - group: credentials jobs: - - job: REST_Sample - displayName: REST Server Sample - pool: - vmImage: ubuntu-20.04 - steps: - - template: templates/asset-transfer-basic/azure-pipelines-rest.yml +# - job: REST_Sample +# displayName: REST Server Sample +# pool: +# vmImage: ubuntu-20.04 +# steps: +# - template: templates/asset-transfer-basic/azure-pipelines-rest.yml - - job: CommercialPaper_Go - displayName: Commercial Paper (Go) - pool: - vmImage: ubuntu-20.04 - steps: - - template: templates/install-deps.yml - - template: templates/commercial-paper/azure-pipelines-go.yml +# - job: CommercialPaper_Go +# displayName: Commercial Paper (Go) +# pool: +# vmImage: ubuntu-20.04 +# steps: +# - template: templates/install-deps.yml +# - template: templates/commercial-paper/azure-pipelines-go.yml - - job: CommercialPaper_Java - displayName: Commercial Paper (Java) - pool: - vmImage: ubuntu-20.04 - steps: - - template: templates/install-deps.yml - - template: templates/commercial-paper/azure-pipelines-java.yml +# - job: CommercialPaper_Java +# displayName: Commercial Paper (Java) +# pool: +# vmImage: ubuntu-20.04 +# steps: +# - template: templates/install-deps.yml +# - template: templates/commercial-paper/azure-pipelines-java.yml - - job: CommercialPaper_JavaScript - displayName: Commercial Paper (JavaScript) - pool: - vmImage: ubuntu-20.04 - steps: - - template: templates/install-deps.yml - - template: templates/commercial-paper/azure-pipelines-javascript.yml +# - job: CommercialPaper_JavaScript +# displayName: Commercial Paper (JavaScript) +# pool: +# vmImage: ubuntu-20.04 +# steps: +# - template: templates/install-deps.yml +# - template: templates/commercial-paper/azure-pipelines-javascript.yml - - job: FabCar_Go - displayName: FabCar (Go) - pool: - vmImage: ubuntu-20.04 - steps: - - template: templates/install-deps.yml - - template: templates/fabcar/azure-pipelines-go.yml +# - job: FabCar_Go +# displayName: FabCar (Go) +# pool: +# vmImage: ubuntu-20.04 +# steps: +# - template: templates/install-deps.yml +# - template: templates/fabcar/azure-pipelines-go.yml - - job: FabCar_Java - displayName: FabCar (Java) - pool: - vmImage: ubuntu-20.04 - steps: - - template: templates/install-deps.yml - - template: templates/fabcar/azure-pipelines-java.yml +# - job: FabCar_Java +# displayName: FabCar (Java) +# pool: +# vmImage: ubuntu-20.04 +# steps: +# - template: templates/install-deps.yml +# - template: templates/fabcar/azure-pipelines-java.yml - - job: FabCar_JavaScript - displayName: FabCar (JavaScript) - pool: - vmImage: ubuntu-20.04 - steps: - - template: templates/install-deps.yml - - template: templates/fabcar/azure-pipelines-javascript.yml +# - job: FabCar_JavaScript +# displayName: FabCar (JavaScript) +# pool: +# vmImage: ubuntu-20.04 +# steps: +# - template: templates/install-deps.yml +# - template: templates/fabcar/azure-pipelines-javascript.yml - - job: Fabcar_TypeScript - displayName: FabCar (TypeScript) - pool: - vmImage: ubuntu-20.04 - steps: - - template: templates/install-deps.yml - - template: templates/fabcar/azure-pipelines-typescript.yml +# - job: Fabcar_TypeScript +# displayName: FabCar (TypeScript) +# pool: +# vmImage: ubuntu-20.04 +# steps: +# - template: templates/install-deps.yml +# - template: templates/fabcar/azure-pipelines-typescript.yml - - job: Lint - displayName: Lint - pool: - vmImage: ubuntu-20.04 - steps: - - task: GoTool@0 - inputs: - goBin: $(GO_BIN) - version: $(GO_VER) - displayName: Install GoLang - - task: NodeTool@0 - inputs: - versionSpec: $(NODE_VER) - displayName: Install Node.js - - script: ./ci/scripts/shellcheck.sh - displayName: Lint Shell Scripts - - script: ./ci/scripts/lint.sh - displayName: Lint Code + # - job: Lint + # displayName: Lint + # pool: + # vmImage: ubuntu-20.04 + # steps: + # - task: GoTool@0 + # inputs: + # goBin: $(GO_BIN) + # version: $(GO_VER) + # displayName: Install GoLang + # - task: NodeTool@0 + # inputs: + # versionSpec: $(NODE_VER) + # displayName: Install Node.js + # - script: ./ci/scripts/shellcheck.sh + # displayName: Lint Shell Scripts + # - script: ./ci/scripts/lint.sh + # displayName: Lint Code - job: TestNetworkBasic displayName: Test Network @@ -124,113 +124,112 @@ jobs: steps: - template: templates/install-deps.yml - - template: templates/install_deps_hsm_ca.yml - - script: sudo apt-get install softhsm2 - displayName: Install SoftHSM + # - template: templates/install-deps-hsm.yml + - template: templates/install-deps-hsm-ca.yml - script: ../ci/scripts/run-test-network-basic.sh workingDirectory: test-network displayName: Run Test Network Basic Chaincode - - job: KubeTestNetworkBasic - displayName: Kube Test Network - pool: - vmImage: ubuntu-20.04 - strategy: - matrix: - CCaaS-Java: - CLIENT_LANGUAGE: typescript - CHAINCODE_LANGUAGE: java - CCaaS-Golang: - CLIENT_LANGUAGE: typescript - CHAINCODE_LANGUAGE: external - K8s-Builder-Java: - CHAINCODE_NAME: basic - CHAINCODE_LANGUAGE: java - CHAINCODE_BUILDER: k8s + # - job: KubeTestNetworkBasic + # displayName: Kube Test Network + # pool: + # vmImage: ubuntu-20.04 + # strategy: + # matrix: + # CCaaS-Java: + # CLIENT_LANGUAGE: typescript + # CHAINCODE_LANGUAGE: java + # CCaaS-Golang: + # CLIENT_LANGUAGE: typescript + # CHAINCODE_LANGUAGE: external + # K8s-Builder-Java: + # CHAINCODE_NAME: basic + # CHAINCODE_LANGUAGE: java + # CHAINCODE_BUILDER: k8s - steps: - - template: templates/install-k8s-deps.yml - - script: ../ci/scripts/run-k8s-test-network-basic.sh - workingDirectory: test-network-k8s - displayName: Run Kubernetes Test Network Basic Asset Transfer + # steps: + # - template: templates/install-k8s-deps.yml + # - script: ../ci/scripts/run-k8s-test-network-basic.sh + # workingDirectory: test-network-k8s + # displayName: Run Kubernetes Test Network Basic Asset Transfer - - job: TestNetworkLedger - displayName: Test Network - pool: - vmImage: ubuntu-20.04 - strategy: - matrix: - Ledger-Go: - CHAINCODE_NAME: ledger - CHAINCODE_LANGUAGE: go - Ledger-Javascript: - CHAINCODE_NAME: ledger - CHAINCODE_LANGUAGE: javascript - steps: - - template: templates/install-deps.yml - - script: ../ci/scripts/run-test-network-ledger.sh - workingDirectory: test-network - displayName: Run Test Network Ledger Chaincode + # - job: TestNetworkLedger + # displayName: Test Network + # pool: + # vmImage: ubuntu-20.04 + # strategy: + # matrix: + # Ledger-Go: + # CHAINCODE_NAME: ledger + # CHAINCODE_LANGUAGE: go + # Ledger-Javascript: + # CHAINCODE_NAME: ledger + # CHAINCODE_LANGUAGE: javascript + # steps: + # - template: templates/install-deps.yml + # - script: ../ci/scripts/run-test-network-ledger.sh + # workingDirectory: test-network + # displayName: Run Test Network Ledger Chaincode - - job: TestNetworkPrivate - displayName: Test Network - pool: - vmImage: ubuntu-20.04 - strategy: - matrix: - Private-Go: - CHAINCODE_NAME: private - CHAINCODE_LANGUAGE: go - steps: - - template: templates/install-deps.yml - - script: ../ci/scripts/run-test-network-private.sh - workingDirectory: test-network - displayName: Run Test Network Private Chaincode + # - job: TestNetworkPrivate + # displayName: Test Network + # pool: + # vmImage: ubuntu-20.04 + # strategy: + # matrix: + # Private-Go: + # CHAINCODE_NAME: private + # CHAINCODE_LANGUAGE: go + # steps: + # - template: templates/install-deps.yml + # - script: ../ci/scripts/run-test-network-private.sh + # workingDirectory: test-network + # displayName: Run Test Network Private Chaincode - - job: TestNetworkSBE - displayName: Test Network - pool: - vmImage: ubuntu-20.04 - strategy: - matrix: - SBE-Typescript: - CHAINCODE_NAME: sbe - CHAINCODE_LANGUAGE: typescript - SBE-Java: - CHAINCODE_NAME: sbe - CHAINCODE_LANGUAGE: java - steps: - - template: templates/install-deps.yml - - script: ../ci/scripts/run-test-network-sbe.sh - workingDirectory: test-network - displayName: Run Test Network SBE Chaincode + # - job: TestNetworkSBE + # displayName: Test Network + # pool: + # vmImage: ubuntu-20.04 + # strategy: + # matrix: + # SBE-Typescript: + # CHAINCODE_NAME: sbe + # CHAINCODE_LANGUAGE: typescript + # SBE-Java: + # CHAINCODE_NAME: sbe + # CHAINCODE_LANGUAGE: java + # steps: + # - template: templates/install-deps.yml + # - script: ../ci/scripts/run-test-network-sbe.sh + # workingDirectory: test-network + # displayName: Run Test Network SBE Chaincode - - job: TestNetworkSecured - displayName: Test Network - pool: - vmImage: ubuntu-20.04 - strategy: - matrix: - Secured-Go: - CHAINCODE_NAME: secured - CHAINCODE_LANGUAGE: go - steps: - - template: templates/install-deps.yml - - script: ../ci/scripts/run-test-network-secured.sh - workingDirectory: test-network - displayName: Run Test Network Secured Chaincode + # - job: TestNetworkSecured + # displayName: Test Network + # pool: + # vmImage: ubuntu-20.04 + # strategy: + # matrix: + # Secured-Go: + # CHAINCODE_NAME: secured + # CHAINCODE_LANGUAGE: go + # steps: + # - template: templates/install-deps.yml + # - script: ../ci/scripts/run-test-network-secured.sh + # workingDirectory: test-network + # displayName: Run Test Network Secured Chaincode - - job: TestNetworkEvents - displayName: Test Network - pool: - vmImage: ubuntu-20.04 - strategy: - matrix: - Events-Javascript: - CHAINCODE_NAME: events - CHAINCODE_LANGUAGE: javascript - steps: - - template: templates/install-deps.yml - - script: ../ci/scripts/run-test-network-events.sh - workingDirectory: test-network - displayName: Run Test Network Events Chaincode + # - job: TestNetworkEvents + # displayName: Test Network + # pool: + # vmImage: ubuntu-20.04 + # strategy: + # matrix: + # Events-Javascript: + # CHAINCODE_NAME: events + # CHAINCODE_LANGUAGE: javascript + # steps: + # - template: templates/install-deps.yml + # - script: ../ci/scripts/run-test-network-events.sh + # workingDirectory: test-network + # displayName: Run Test Network Events Chaincode diff --git a/ci/scripts/run-test-network-basic.sh b/ci/scripts/run-test-network-basic.sh index 0c87993c..ba3fc85f 100755 --- a/ci/scripts/run-test-network-basic.sh +++ b/ci/scripts/run-test-network-basic.sh @@ -26,66 +26,66 @@ function stopNetwork() { ./network.sh down } -# Run Go application -createNetwork -print "Initializing Go application" -pushd ../asset-transfer-basic/application-go -print "Executing AssetTransfer.go" -go run . -popd -stopNetwork +# # Run Go application +# createNetwork +# print "Initializing Go application" +# pushd ../asset-transfer-basic/application-go +# print "Executing AssetTransfer.go" +# go run . +# popd +# stopNetwork -# Run Java application -createNetwork -print "Initializing Java application" -pushd ../asset-transfer-basic/application-java -print "Executing Gradle Run" -gradle run -popd -stopNetwork +# # Run Java application +# createNetwork +# print "Initializing Java application" +# pushd ../asset-transfer-basic/application-java +# print "Executing Gradle Run" +# gradle run +# popd +# stopNetwork -# Run Java application using gateway -createNetwork -print "Initializing Java application" -pushd ../asset-transfer-basic/application-gateway-java -print "Executing Gradle Run" -./gradlew run -popd -stopNetwork +# # Run Java application using gateway +# createNetwork +# print "Initializing Java application" +# pushd ../asset-transfer-basic/application-gateway-java +# print "Executing Gradle Run" +# ./gradlew run +# popd +# stopNetwork -# Run Javascript application -createNetwork -print "Initializing Javascript application" -pushd ../asset-transfer-basic/application-javascript -npm install -print "Executing app.js" -node app.js -popd -stopNetwork +# # Run Javascript application +# createNetwork +# print "Initializing Javascript application" +# pushd ../asset-transfer-basic/application-javascript +# npm install +# print "Executing app.js" +# node app.js +# popd +# stopNetwork -# Run typescript application -createNetwork -print "Initializing Typescript application" -pushd ../asset-transfer-basic/application-typescript -npm install -print "Building app.ts" -npm run build -print "Running the output app" -node dist/app.js -popd -stopNetwork +# # Run typescript application +# createNetwork +# print "Initializing Typescript application" +# pushd ../asset-transfer-basic/application-typescript +# npm install +# print "Building app.ts" +# npm run build +# print "Running the output app" +# node dist/app.js +# popd +# stopNetwork -# Run gateway typescript application -createNetwork -print "Initializing Typescript gateway application" -pushd ../asset-transfer-basic/application-gateway-typescript -npm install -print "Building app.ts" -npm run build -print "Running the output app" -node dist/app.js -popd -stopNetwork +# # Run gateway typescript application +# createNetwork +# print "Initializing Typescript gateway application" +# pushd ../asset-transfer-basic/application-gateway-typescript +# npm install +# print "Building app.ts" +# npm run build +# print "Running the output app" +# node dist/app.js +# popd +# stopNetwork # Run typescript HSM application createNetwork @@ -93,7 +93,6 @@ print "Initializing Typescript HSM application" pushd ../asset-transfer-basic/application-typescript-hsm print "Setup SoftHSM" export SOFTHSM2_CONF=$PWD/softhsm2.conf -softhsm2-util --init-token --slot 0 --label "ForFabric" --pin 98765432 --so-pin 1234 print "install dependencies" npm install print "Building app.ts" @@ -106,11 +105,9 @@ stopNetwork # Run Typescript HSM gateway application createNetwork print "Initializing Typescript HSM gateway application" -pushd ../asset-transfer-basic/application-gateway-hsm/ +pushd ../asset-transfer-basic/application-gateway-hsm/scripts/ print "Setup SoftHSM" -export SOFTHSM2_CONF=$PWD/softhsm2.conf -softhsm2-util --init-token --slot 1 --label "ForFabric" --pin 98765432 --so-pin 1234 -pushd scripts +export SOFTHSM2_CONF=$HOME/softhsm2.conf print "Enroll and register User in HSM" ./generate-hsm-user.sh HSMUser pushd ../node @@ -126,11 +123,9 @@ stopNetwork # Run Go HSM gateway application createNetwork print "Initializing Go HSM gateway application" -pushd ../asset-transfer-basic/application-gateway-hsm/ +pushd ../asset-transfer-basic/application-gateway-hsm/scripts/ print "Setup SoftHSM" -export SOFTHSM2_CONF=$PWD/softhsm2.conf -softhsm2-util --init-token --slot 2 --label "ForFabric" --pin 98765432 --so-pin 1234 -pushd scripts +export SOFTHSM2_CONF=$HOME/softhsm2.conf print "Register and enroll user in HSM" ./generate-hsm-user.sh HSMUser pushd ../go @@ -139,34 +134,34 @@ go run -tags pkcs11 hsm-sample.go popd stopNetwork -# Run Go gateway application -createNetwork -print "Initializing Go gateway application" -pushd ../asset-transfer-basic/application-gateway-go -print "Executing AssetTransfer.go" -go run . -popd -stopNetwork +# # Run Go gateway application +# createNetwork +# print "Initializing Go gateway application" +# pushd ../asset-transfer-basic/application-gateway-go +# print "Executing AssetTransfer.go" +# go run . +# popd +# stopNetwork -# Run off-chain data TypeScript application -createNetwork -print "Initializing Typescript off-chain data application" -pushd ../off_chain_data/application-typescript -rm -f checkpoint.json store.log -npm install -print "Running the output app" -SIMULATED_FAILURE_COUNT=1 npm start getAllAssets transact getAllAssets listen -SIMULATED_FAILURE_COUNT=1 npm start listen -popd -stopNetwork +# # Run off-chain data TypeScript application +# createNetwork +# print "Initializing Typescript off-chain data application" +# pushd ../off_chain_data/application-typescript +# rm -f checkpoint.json store.log +# npm install +# print "Running the output app" +# SIMULATED_FAILURE_COUNT=1 npm start getAllAssets transact getAllAssets listen +# SIMULATED_FAILURE_COUNT=1 npm start listen +# popd +# stopNetwork -# Run off-chain data Java application -createNetwork -print "Initializing Typescript off-chain data application" -pushd ../off_chain_data/application-java -rm -f app/checkpoint.json app/store.log -print "Running the output app" -SIMULATED_FAILURE_COUNT=1 ./gradlew run --quiet --args='getAllAssets transact getAllAssets listen' -SIMULATED_FAILURE_COUNT=1 ./gradlew run --quiet --args=listen -popd -stopNetwork +# # Run off-chain data Java application +# createNetwork +# print "Initializing Typescript off-chain data application" +# pushd ../off_chain_data/application-java +# rm -f app/checkpoint.json app/store.log +# print "Running the output app" +# SIMULATED_FAILURE_COUNT=1 ./gradlew run --quiet --args='getAllAssets transact getAllAssets listen' +# SIMULATED_FAILURE_COUNT=1 ./gradlew run --quiet --args=listen +# popd +# stopNetwork diff --git a/ci/templates/install_deps_hsm_ca.yml b/ci/templates/install-deps-hsm-ca.yml similarity index 85% rename from ci/templates/install_deps_hsm_ca.yml rename to ci/templates/install-deps-hsm-ca.yml index eb58bc3e..cd92132b 100644 --- a/ci/templates/install_deps_hsm_ca.yml +++ b/ci/templates/install-deps-hsm-ca.yml @@ -3,6 +3,6 @@ # steps: - - template: install_deps_hsm.yml + - template: install-deps-hsm.yml - script: go install -tags pkcs11 github.com/hyperledger/fabric-ca/cmd/fabric-ca-client@latest displayName: Install Fabric-ca-client with HSM Support \ No newline at end of file diff --git a/ci/templates/install-deps-hsm.yml b/ci/templates/install-deps-hsm.yml new file mode 100644 index 00000000..f802a3eb --- /dev/null +++ b/ci/templates/install-deps-hsm.yml @@ -0,0 +1,13 @@ +# +# SPDX-License-Identifier: Apache-2.0 +# + +steps: + - script: | + sudo apt install -y softhsm2 + displayName: Install SoftHSM + - script: | + echo directories.tokendir = /tmp > $HOME/softhsm2.conf + export SOFTHSM2_CONF=$HOME/softhsm2.conf + softhsm2-util --init-token --slot 0 --label "ForFabric" --pin 98765432 --so-pin 1234 + displayName: Set up SoftHSM \ No newline at end of file