fabric icon indicating copy to clipboard operation
fabric copied to clipboard

Adding softhsm2 support for fabric peer

Open chetagra opened this issue 2 years ago • 2 comments

I am trying to configure fabric peer with Softhsm2 support

I am getting following error on starting peer container

Screenshot from 2023-04-19 18-12-55

below is peer dockerfile I am using

# Copyright IBM Corp. All Rights Reserved.
#
# SPDX-License-Identifier: Apache-2.0

ARG GO_VER
ARG UBUNTU_VER

FROM ubuntu:${UBUNTU_VER} as peer-base
RUN apt update && apt install -y tzdata
# set up nsswitch.conf for Go's "netgo" implementation
# - https://github.com/golang/go/blob/go1.9.1/src/net/conf.go#L194-L275
# - docker run --rm debian:stretch grep '^hosts:' /etc/nsswitch.conf
RUN echo 'hosts: files dns' > /etc/nsswitch.conf

FROM golang:${GO_VER} as golang
RUN apt update && apt install -y \
	bash \
	gcc \
	git \
	make \
	musl-dev
ADD . /home/chetan/fabric
WORKDIR /home/chetan/fabric

FROM golang as peer
ARG GO_TAGS
RUN make peer GO_TAGS=${GO_TAGS}

FROM peer-base
RUN apt update && apt install -y \
	build-essential \ 
	libltdl-dev \
	libssl-dev \  
	automake \
	autoconf \
	libtool \
	git \
	make \
	wget \
	opensc
RUN wget https://dist.opendnssec.org/source/softhsm-2.6.1.tar.gz
RUN tar -xzf softhsm-2.6.1.tar.gz
RUN cd softhsm-2.6.1
RUN ./softhsm-2.6.1/configure
RUN make
RUN make install
ENV SOFTHSM2_CONF /etc/softhsm2.conf
RUN softhsm2-util --init-token --slot 0 --label "fabric" --pin 1234 --so-pin 1234
RUN pkcs11-tool --module /usr/local/lib/softhsm/libsofthsm2.so --label fabric --pin 1234 --login --keypairgen --key-type EC:prime256v1
ENV FABRIC_CFG_PATH /etc/hyperledger/fabric
VOLUME /etc/hyperledger/fabric
VOLUME /var/hyperledger
COPY --from=peer /home/chetan/fabric/build/bin /usr/local/bin
COPY --from=peer /home/chetan/fabric/sampleconfig/msp ${FABRIC_CFG_PATH}/msp
COPY --from=peer /home/chetan/fabric/sampleconfig/core.yaml ${FABRIC_CFG_PATH}
EXPOSE 7051
CMD ["peer","node","start"]

below are the core.yaml file changes I have made

Screenshot from 2023-04-19 18-23-19

I am folllowing this documentation :- https://hyperledger-fabric.readthedocs.io/en/latest/hsm.html

chetagra avatar Apr 19 '23 12:04 chetagra

I wonder if this is related to #4146? Comments further down that issues suggested it was solved by changing the config file location.

bestbeforetoday avatar Apr 20 '23 09:04 bestbeforetoday

I tried these solution but doesn't seem to work I am using fabric v2.2.10

chetagra avatar Apr 20 '23 12:04 chetagra