mirror of
https://github.com/hyperledger/fabric-samples.git
synced 2026-06-22 17:45:10 +00:00
Remove TLS enabled switch (#155)
Signed-off-by: NIKHIL E GUPTA <negupta@us.ibm.com> Co-authored-by: NIKHIL E GUPTA <negupta@us.ibm.com>
This commit is contained in:
parent
381fb465be
commit
aa9b577f65
5 changed files with 36 additions and 99 deletions
|
|
@ -50,23 +50,15 @@ createAncorPeerTx() {
|
||||||
|
|
||||||
createChannel() {
|
createChannel() {
|
||||||
setGlobals 1
|
setGlobals 1
|
||||||
|
|
||||||
# Poll in case the raft leader is not set yet
|
# Poll in case the raft leader is not set yet
|
||||||
local rc=1
|
local rc=1
|
||||||
local COUNTER=1
|
local COUNTER=1
|
||||||
while [ $rc -ne 0 -a $COUNTER -lt $MAX_RETRY ] ; do
|
while [ $rc -ne 0 -a $COUNTER -lt $MAX_RETRY ] ; do
|
||||||
sleep $DELAY
|
sleep $DELAY
|
||||||
if [ -z "$CORE_PEER_TLS_ENABLED" -o "$CORE_PEER_TLS_ENABLED" = "false" ]; then
|
set -x
|
||||||
set -x
|
peer channel create -o localhost:7050 -c $CHANNEL_NAME --ordererTLSHostnameOverride orderer.example.com -f ./channel-artifacts/${CHANNEL_NAME}.tx --outputBlock ./channel-artifacts/${CHANNEL_NAME}.block --tls $CORE_PEER_TLS_ENABLED --cafile $ORDERER_CA >&log.txt
|
||||||
peer channel create -o localhost:7050 -c $CHANNEL_NAME -f ./channel-artifacts/${CHANNEL_NAME}.tx --outputBlock ./channel-artifacts/${CHANNEL_NAME}.block >&log.txt
|
res=$?
|
||||||
res=$?
|
set +x
|
||||||
set +x
|
|
||||||
else
|
|
||||||
set -x
|
|
||||||
peer channel create -o localhost:7050 -c $CHANNEL_NAME --ordererTLSHostnameOverride orderer.example.com -f ./channel-artifacts/${CHANNEL_NAME}.tx --outputBlock ./channel-artifacts/${CHANNEL_NAME}.block --tls $CORE_PEER_TLS_ENABLED --cafile $ORDERER_CA >&log.txt
|
|
||||||
res=$?
|
|
||||||
set +x
|
|
||||||
fi
|
|
||||||
let rc=$res
|
let rc=$res
|
||||||
COUNTER=$(expr $COUNTER + 1)
|
COUNTER=$(expr $COUNTER + 1)
|
||||||
done
|
done
|
||||||
|
|
@ -101,19 +93,19 @@ joinChannel() {
|
||||||
updateAnchorPeers() {
|
updateAnchorPeers() {
|
||||||
ORG=$1
|
ORG=$1
|
||||||
setGlobals $ORG
|
setGlobals $ORG
|
||||||
|
local rc=1
|
||||||
if [ -z "$CORE_PEER_TLS_ENABLED" -o "$CORE_PEER_TLS_ENABLED" = "false" ]; then
|
local COUNTER=1
|
||||||
|
## Sometimes Join takes time, hence retry
|
||||||
|
while [ $rc -ne 0 -a $COUNTER -lt $MAX_RETRY ] ; do
|
||||||
|
sleep $DELAY
|
||||||
set -x
|
set -x
|
||||||
peer channel update -o localhost:7050 --ordererTLSHostnameOverride orderer.example.com -c $CHANNEL_NAME -f ./channel-artifacts/${CORE_PEER_LOCALMSPID}anchors.tx >&log.txt
|
peer channel update -o localhost:7050 --ordererTLSHostnameOverride orderer.example.com -c $CHANNEL_NAME -f ./channel-artifacts/${CORE_PEER_LOCALMSPID}anchors.tx --tls $CORE_PEER_TLS_ENABLED --cafile $ORDERER_CA >&log.txt
|
||||||
res=$?
|
res=$?
|
||||||
set +x
|
set +x
|
||||||
else
|
let rc=$res
|
||||||
set -x
|
COUNTER=$(expr $COUNTER + 1)
|
||||||
peer channel update -o localhost:7050 --ordererTLSHostnameOverride orderer.example.com -c $CHANNEL_NAME -f ./channel-artifacts/${CORE_PEER_LOCALMSPID}anchors.tx --tls $CORE_PEER_TLS_ENABLED --cafile $ORDERER_CA >&log.txt
|
done
|
||||||
res=$?
|
cat log.txt
|
||||||
set +x
|
|
||||||
fi
|
|
||||||
cat log.txt
|
|
||||||
verifyResult $res "Anchor peer update failed"
|
verifyResult $res "Anchor peer update failed"
|
||||||
echo "===================== Anchor peers updated for org '$CORE_PEER_LOCALMSPID' on channel '$CHANNEL_NAME' ===================== "
|
echo "===================== Anchor peers updated for org '$CORE_PEER_LOCALMSPID' on channel '$CHANNEL_NAME' ===================== "
|
||||||
sleep $DELAY
|
sleep $DELAY
|
||||||
|
|
|
||||||
|
|
@ -107,16 +107,9 @@ queryInstalled() {
|
||||||
approveForMyOrg() {
|
approveForMyOrg() {
|
||||||
ORG=$1
|
ORG=$1
|
||||||
setGlobals $ORG
|
setGlobals $ORG
|
||||||
|
set -x
|
||||||
if [ -z "$CORE_PEER_TLS_ENABLED" -o "$CORE_PEER_TLS_ENABLED" = "false" ] ; then
|
peer lifecycle chaincode approveformyorg -o localhost:7050 --ordererTLSHostnameOverride orderer.example.com --tls $CORE_PEER_TLS_ENABLED --cafile $ORDERER_CA --channelID $CHANNEL_NAME --name fabcar --version ${VERSION} --init-required --package-id ${PACKAGE_ID} --sequence ${VERSION} >&log.txt
|
||||||
set -x
|
set +x
|
||||||
peer lifecycle chaincode approveformyorg -o localhost:7050 --channelID $CHANNEL_NAME --name fabcar --version ${VERSION} --init-required --package-id ${PACKAGE_ID} --sequence ${VERSION} --waitForEvent >&log.txt
|
|
||||||
set +x
|
|
||||||
else
|
|
||||||
set -x
|
|
||||||
peer lifecycle chaincode approveformyorg -o localhost:7050 --ordererTLSHostnameOverride orderer.example.com --tls $CORE_PEER_TLS_ENABLED --cafile $ORDERER_CA --channelID $CHANNEL_NAME --name fabcar --version ${VERSION} --init-required --package-id ${PACKAGE_ID} --sequence ${VERSION} >&log.txt
|
|
||||||
set +x
|
|
||||||
fi
|
|
||||||
cat log.txt
|
cat log.txt
|
||||||
verifyResult $res "Chaincode definition approved on peer0.org${ORG} on channel '$CHANNEL_NAME' failed"
|
verifyResult $res "Chaincode definition approved on peer0.org${ORG} on channel '$CHANNEL_NAME' failed"
|
||||||
echo "===================== Chaincode definition approved on peer0.org${ORG} on channel '$CHANNEL_NAME' ===================== "
|
echo "===================== Chaincode definition approved on peer0.org${ORG} on channel '$CHANNEL_NAME' ===================== "
|
||||||
|
|
@ -140,7 +133,6 @@ checkCommitReadiness() {
|
||||||
peer lifecycle chaincode checkcommitreadiness --channelID $CHANNEL_NAME --name fabcar --version ${VERSION} --sequence ${VERSION} --output json --init-required >&log.txt
|
peer lifecycle chaincode checkcommitreadiness --channelID $CHANNEL_NAME --name fabcar --version ${VERSION} --sequence ${VERSION} --output json --init-required >&log.txt
|
||||||
res=$?
|
res=$?
|
||||||
set +x
|
set +x
|
||||||
#test $res -eq 0 || continue
|
|
||||||
let rc=0
|
let rc=0
|
||||||
for var in "$@"
|
for var in "$@"
|
||||||
do
|
do
|
||||||
|
|
@ -167,17 +159,10 @@ commitChaincodeDefinition() {
|
||||||
# while 'peer chaincode' command can get the orderer endpoint from the
|
# while 'peer chaincode' command can get the orderer endpoint from the
|
||||||
# peer (if join was successful), let's supply it directly as we know
|
# peer (if join was successful), let's supply it directly as we know
|
||||||
# it using the "-o" option
|
# it using the "-o" option
|
||||||
if [ -z "$CORE_PEER_TLS_ENABLED" -o "$CORE_PEER_TLS_ENABLED" = "false" ] ; then
|
set -x
|
||||||
set -x
|
peer lifecycle chaincode commit -o localhost:7050 --ordererTLSHostnameOverride orderer.example.com --tls $CORE_PEER_TLS_ENABLED --cafile $ORDERER_CA --channelID $CHANNEL_NAME --name fabcar $PEER_CONN_PARMS --version ${VERSION} --sequence ${VERSION} --init-required >&log.txt
|
||||||
peer lifecycle chaincode commit -o localhost:7050 --channelID $CHANNEL_NAME --name fabcar $PEER_CONN_PARMS --version ${VERSION} --sequence ${VERSION} --init-required >&log.txt
|
res=$?
|
||||||
res=$?
|
set +x
|
||||||
set +x
|
|
||||||
else
|
|
||||||
set -x
|
|
||||||
peer lifecycle chaincode commit -o localhost:7050 --ordererTLSHostnameOverride orderer.example.com --tls $CORE_PEER_TLS_ENABLED --cafile $ORDERER_CA --channelID $CHANNEL_NAME --name fabcar $PEER_CONN_PARMS --version ${VERSION} --sequence ${VERSION} --init-required >&log.txt
|
|
||||||
res=$?
|
|
||||||
set +x
|
|
||||||
fi
|
|
||||||
cat log.txt
|
cat log.txt
|
||||||
verifyResult $res "Chaincode definition commit failed on peer0.org${ORG} on channel '$CHANNEL_NAME' failed"
|
verifyResult $res "Chaincode definition commit failed on peer0.org${ORG} on channel '$CHANNEL_NAME' failed"
|
||||||
echo "===================== Chaincode definition committed on channel '$CHANNEL_NAME' ===================== "
|
echo "===================== Chaincode definition committed on channel '$CHANNEL_NAME' ===================== "
|
||||||
|
|
@ -225,17 +210,10 @@ chaincodeInvokeInit() {
|
||||||
# while 'peer chaincode' command can get the orderer endpoint from the
|
# while 'peer chaincode' command can get the orderer endpoint from the
|
||||||
# peer (if join was successful), let's supply it directly as we know
|
# peer (if join was successful), let's supply it directly as we know
|
||||||
# it using the "-o" option
|
# it using the "-o" option
|
||||||
if [ -z "$CORE_PEER_TLS_ENABLED" -o "$CORE_PEER_TLS_ENABLED" = "false" ]; then
|
set -x
|
||||||
set -x
|
peer chaincode invoke -o localhost:7050 --ordererTLSHostnameOverride orderer.example.com --tls $CORE_PEER_TLS_ENABLED --cafile $ORDERER_CA -C $CHANNEL_NAME -n fabcar $PEER_CONN_PARMS --isInit -c '{"function":"initLedger","Args":[]}' >&log.txt
|
||||||
peer chaincode invoke -o localhost:7050 -C $CHANNEL_NAME -n fabcar $PEER_CONN_PARMS --isInit -c '{"function":"initLedger","Args":[]}' >&log.txt
|
res=$?
|
||||||
res=$?
|
set +x
|
||||||
set +x
|
|
||||||
else
|
|
||||||
set -x
|
|
||||||
peer chaincode invoke -o localhost:7050 --ordererTLSHostnameOverride orderer.example.com --tls $CORE_PEER_TLS_ENABLED --cafile $ORDERER_CA -C $CHANNEL_NAME -n fabcar $PEER_CONN_PARMS --isInit -c '{"function":"initLedger","Args":[]}' >&log.txt
|
|
||||||
res=$?
|
|
||||||
set +x
|
|
||||||
fi
|
|
||||||
cat log.txt
|
cat log.txt
|
||||||
verifyResult $res "Invoke execution on $PEERS failed "
|
verifyResult $res "Invoke execution on $PEERS failed "
|
||||||
echo "===================== Invoke transaction successful on $PEERS on channel '$CHANNEL_NAME' ===================== "
|
echo "===================== Invoke transaction successful on $PEERS on channel '$CHANNEL_NAME' ===================== "
|
||||||
|
|
|
||||||
|
|
@ -25,7 +25,7 @@ setGlobals() {
|
||||||
if [ -z "$OVERRIDE_ORG" ]; then
|
if [ -z "$OVERRIDE_ORG" ]; then
|
||||||
USING_ORG=$1
|
USING_ORG=$1
|
||||||
else
|
else
|
||||||
USING_ORG="${OVERRIDE_ORG}"
|
USING_ORG="${OVERRIDE_ORG}"
|
||||||
fi
|
fi
|
||||||
echo "Using organization ${USING_ORG}"
|
echo "Using organization ${USING_ORG}"
|
||||||
if [ $USING_ORG -eq 1 ]; then
|
if [ $USING_ORG -eq 1 ]; then
|
||||||
|
|
@ -54,24 +54,22 @@ setGlobals() {
|
||||||
}
|
}
|
||||||
|
|
||||||
# parsePeerConnectionParameters $@
|
# parsePeerConnectionParameters $@
|
||||||
# Helper function that takes the parameters from a chaincode operation
|
# Helper function that sets the peer connection parameters for a chaincode
|
||||||
# (e.g. invoke, query, instantiate) and checks for an even number of
|
# operation
|
||||||
# peers and associated org, then sets $PEER_CONN_PARMS and $PEERS
|
|
||||||
parsePeerConnectionParameters() {
|
parsePeerConnectionParameters() {
|
||||||
# check for uneven number of peer and org parameters
|
|
||||||
|
|
||||||
PEER_CONN_PARMS=""
|
PEER_CONN_PARMS=""
|
||||||
PEERS=""
|
PEERS=""
|
||||||
while [ "$#" -gt 0 ]; do
|
while [ "$#" -gt 0 ]; do
|
||||||
setGlobals $1
|
setGlobals $1
|
||||||
PEER="peer0.org$1"
|
PEER="peer0.org$1"
|
||||||
|
## Set peer adresses
|
||||||
PEERS="$PEERS $PEER"
|
PEERS="$PEERS $PEER"
|
||||||
PEER_CONN_PARMS="$PEER_CONN_PARMS --peerAddresses $CORE_PEER_ADDRESS"
|
PEER_CONN_PARMS="$PEER_CONN_PARMS --peerAddresses $CORE_PEER_ADDRESS"
|
||||||
if [ -z "$CORE_PEER_TLS_ENABLED" -o "$CORE_PEER_TLS_ENABLED" = "true" ]; then
|
## Set path to TLS certificate
|
||||||
TLSINFO=$(eval echo "--tlsRootCertFiles \$PEER0_ORG$1_CA")
|
TLSINFO=$(eval echo "--tlsRootCertFiles \$PEER0_ORG$1_CA")
|
||||||
PEER_CONN_PARMS="$PEER_CONN_PARMS $TLSINFO"
|
PEER_CONN_PARMS="$PEER_CONN_PARMS $TLSINFO"
|
||||||
fi
|
# shift by one to get to the next organization
|
||||||
# shift by two to get the next pair of peer/org parameters
|
|
||||||
shift
|
shift
|
||||||
done
|
done
|
||||||
# remove leading space for output
|
# remove leading space for output
|
||||||
|
|
|
||||||
|
|
@ -45,31 +45,6 @@ setGlobals() {
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
# parsePeerConnectionParameters $@
|
|
||||||
# Helper function that takes the parameters from a chaincode operation
|
|
||||||
# (e.g. invoke, query, instantiate) and checks for an even number of
|
|
||||||
# peers and associated org, then sets $PEER_CONN_PARMS and $PEERS
|
|
||||||
parsePeerConnectionParameters() {
|
|
||||||
# check for uneven number of peer and org parameters
|
|
||||||
|
|
||||||
PEER_CONN_PARMS=""
|
|
||||||
PEERS=""
|
|
||||||
while [ "$#" -gt 0 ]; do
|
|
||||||
setGlobals $1
|
|
||||||
PEER="peer0.org$1"
|
|
||||||
PEERS="$PEERS $PEER"
|
|
||||||
PEER_CONN_PARMS="$PEER_CONN_PARMS --peerAddresses $CORE_PEER_ADDRESS"
|
|
||||||
if [ -z "$CORE_PEER_TLS_ENABLED" -o "$CORE_PEER_TLS_ENABLED" = "true" ]; then
|
|
||||||
TLSINFO=$(eval echo "--tlsRootCertFiles \$PEER0_ORG$1_CA")
|
|
||||||
PEER_CONN_PARMS="$PEER_CONN_PARMS $TLSINFO"
|
|
||||||
fi
|
|
||||||
# shift by two to get the next pair of peer/org parameters
|
|
||||||
shift
|
|
||||||
done
|
|
||||||
# remove leading space for output
|
|
||||||
PEERS="$(echo -e "$PEERS" | sed -e 's/^[[:space:]]*//')"
|
|
||||||
}
|
|
||||||
|
|
||||||
verifyResult() {
|
verifyResult() {
|
||||||
if [ $1 -ne 0 ]; then
|
if [ $1 -ne 0 ]; then
|
||||||
echo "!!!!!!!!!!!!!!! "$2" !!!!!!!!!!!!!!!!"
|
echo "!!!!!!!!!!!!!!! "$2" !!!!!!!!!!!!!!!!"
|
||||||
|
|
|
||||||
|
|
@ -38,15 +38,9 @@ fetchChannelConfig() {
|
||||||
setGlobals $ORG
|
setGlobals $ORG
|
||||||
|
|
||||||
echo "Fetching the most recent configuration block for the channel"
|
echo "Fetching the most recent configuration block for the channel"
|
||||||
if [ -z "$CORE_PEER_TLS_ENABLED" -o "$CORE_PEER_TLS_ENABLED" = "false" ]; then
|
set -x
|
||||||
set -x
|
peer channel fetch config config_block.pb -o orderer.example.com:7050 --ordererTLSHostnameOverride orderer.example.com -c $CHANNEL --tls --cafile $ORDERER_CA
|
||||||
peer channel fetch config config_block.pb -o orderer.example.com:7050 -c $CHANNEL --cafile $ORDERER_CA
|
set +x
|
||||||
set +x
|
|
||||||
else
|
|
||||||
set -x
|
|
||||||
peer channel fetch config config_block.pb -o orderer.example.com:7050 --ordererTLSHostnameOverride orderer.example.com -c $CHANNEL --tls --cafile $ORDERER_CA
|
|
||||||
set +x
|
|
||||||
fi
|
|
||||||
|
|
||||||
echo "Decoding config block to JSON and isolating config to ${OUTPUT}"
|
echo "Decoding config block to JSON and isolating config to ${OUTPUT}"
|
||||||
set -x
|
set -x
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue