Skip to content

Commit

Permalink
[FAB-12670] Fix pkcs11 UT Failures
Browse files Browse the repository at this point in the history
This patch allows to initialize softhsm2 token
as non-root user, by merely setting SOFTHSM2_CONF,
CI Envrionment should be updated to leverage SOFTHSM2_CONF.

Change-Id: I9fdc9c837859a78619d9edc9e2e3fbe8733f04af
Signed-off-by: Krishna Harsha Voora <krishvoor@in.ibm.com>
  • Loading branch information
krishvoor authored and ale-linux committed Dec 4, 2018
1 parent f4b1a7e commit af5e9f0
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 2 deletions.
6 changes: 5 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
# - orderer - builds a native fabric orderer binary
# - release - builds release packages for the host platform
# - release-all - builds release packages for all target platforms
# - softhsm2_initialization - generates softhsm2 tokens used in pkcs11 test
# - unit-test - runs the go-test based unit tests
# - verify - runs unit tests for only the changed package tree
# - profile - runs unit tests for all packages in coverprofile mode (slow)
Expand Down Expand Up @@ -183,7 +184,10 @@ ccenv: $(BUILD_DIR)/image/ccenv/$(DUMMY)
integration-test: gotool.ginkgo ccenv docker-thirdparty
./scripts/run-integration-tests.sh

unit-test: unit-test-clean peer-docker docker-thirdparty ccenv
softhsm2_initialization:
./scripts/config_softhsm2.sh

unit-test: unit-test-clean peer-docker softhsm2_initialization docker-thirdparty ccenv
unit-test/run.sh

unit-tests: unit-test
Expand Down
4 changes: 4 additions & 0 deletions devenv/setupRHELonZ.sh
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,10 @@ fi
iptables -I INPUT 1 -j ACCEPT
sysctl vm.overcommit_memory=1

##################
# Install softhsm2
yum install softhsm -y

##################
# Install Docker
cd /tmp
Expand Down
2 changes: 1 addition & 1 deletion devenv/setupUbuntuOnPPC64le.sh
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ fi
# Install pre-requisite OS packages #
#####################################
apt-get update
apt-get -y install software-properties-common curl git sudo wget "build-essential" zlib1g-dev libbz2-dev
apt-get -y install software-properties-common curl git sudo wget "build-essential" zlib1g-dev libbz2-dev softhsm2

#####################################
# Install and setup Docker services #
Expand Down
8 changes: 8 additions & 0 deletions docs/source/dev-setup/devenv.rst
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,14 @@ Prerequisites
- Note: The BIOS Enabled Virtualization may be within the CPU or
Security settings of the BIOS

- (macOS) `Install softhsm on Mac OSX <http://macappstore.org/softhsm/>`__.You can
use Homebrew to install it as follows:

::

brew install softhsm


``pip``
~~~~~~

Expand Down
16 changes: 16 additions & 0 deletions scripts/config_softhsm2.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#!/bin/bash
#
# Copyright IBM Corp. All Rights Reserved.
#
# SPDX-License-Identifier: Apache-2.0
#

cd $HOME
mkdir -p $HOME/lib/softhsm/tokens
cd $HOME/lib/softhsm/
echo "directories.tokendir = $PWD/tokens" > softhsm2.conf
echo "Update SOFTHSM2_CONF via export SOFTHSM2_CONF=$HOME/lib/softhsm/softhsm2.conf"

export SOFTHSM2_CONF=$HOME/lib/softhsm/softhsm2.conf

softhsm2-util --init-token --slot 0 --label "ForFabric" --so-pin 1234 --pin 98765432

0 comments on commit af5e9f0

Please sign in to comment.