Skip to content

Commit aa9b577

Browse files
nikhil550NIKHIL E GUPTA
and
NIKHIL E GUPTA
authored
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>
1 parent 381fb46 commit aa9b577

File tree

5 files changed

+36
-99
lines changed

5 files changed

+36
-99
lines changed

test-network/scripts/createChannel.sh

+14-22
Original file line numberDiff line numberDiff line change
@@ -50,23 +50,15 @@ createAncorPeerTx() {
5050

5151
createChannel() {
5252
setGlobals 1
53-
5453
# Poll in case the raft leader is not set yet
5554
local rc=1
5655
local COUNTER=1
5756
while [ $rc -ne 0 -a $COUNTER -lt $MAX_RETRY ] ; do
5857
sleep $DELAY
59-
if [ -z "$CORE_PEER_TLS_ENABLED" -o "$CORE_PEER_TLS_ENABLED" = "false" ]; then
60-
set -x
61-
peer channel create -o localhost:7050 -c $CHANNEL_NAME -f ./channel-artifacts/${CHANNEL_NAME}.tx --outputBlock ./channel-artifacts/${CHANNEL_NAME}.block >&log.txt
62-
res=$?
63-
set +x
64-
else
65-
set -x
66-
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
67-
res=$?
68-
set +x
69-
fi
58+
set -x
59+
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
60+
res=$?
61+
set +x
7062
let rc=$res
7163
COUNTER=$(expr $COUNTER + 1)
7264
done
@@ -101,19 +93,19 @@ joinChannel() {
10193
updateAnchorPeers() {
10294
ORG=$1
10395
setGlobals $ORG
104-
105-
if [ -z "$CORE_PEER_TLS_ENABLED" -o "$CORE_PEER_TLS_ENABLED" = "false" ]; then
106-
set -x
107-
peer channel update -o localhost:7050 --ordererTLSHostnameOverride orderer.example.com -c $CHANNEL_NAME -f ./channel-artifacts/${CORE_PEER_LOCALMSPID}anchors.tx >&log.txt
108-
res=$?
109-
set +x
110-
else
96+
local rc=1
97+
local COUNTER=1
98+
## Sometimes Join takes time, hence retry
99+
while [ $rc -ne 0 -a $COUNTER -lt $MAX_RETRY ] ; do
100+
sleep $DELAY
111101
set -x
112-
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
102+
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
113103
res=$?
114104
set +x
115-
fi
116-
cat log.txt
105+
let rc=$res
106+
COUNTER=$(expr $COUNTER + 1)
107+
done
108+
cat log.txt
117109
verifyResult $res "Anchor peer update failed"
118110
echo "===================== Anchor peers updated for org '$CORE_PEER_LOCALMSPID' on channel '$CHANNEL_NAME' ===================== "
119111
sleep $DELAY

test-network/scripts/deployCC.sh

+11-33
Original file line numberDiff line numberDiff line change
@@ -107,16 +107,9 @@ queryInstalled() {
107107
approveForMyOrg() {
108108
ORG=$1
109109
setGlobals $ORG
110-
111-
if [ -z "$CORE_PEER_TLS_ENABLED" -o "$CORE_PEER_TLS_ENABLED" = "false" ] ; then
112-
set -x
113-
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
114-
set +x
115-
else
116-
set -x
117-
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
118-
set +x
119-
fi
110+
set -x
111+
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
112+
set +x
120113
cat log.txt
121114
verifyResult $res "Chaincode definition approved on peer0.org${ORG} on channel '$CHANNEL_NAME' failed"
122115
echo "===================== Chaincode definition approved on peer0.org${ORG} on channel '$CHANNEL_NAME' ===================== "
@@ -140,7 +133,6 @@ checkCommitReadiness() {
140133
peer lifecycle chaincode checkcommitreadiness --channelID $CHANNEL_NAME --name fabcar --version ${VERSION} --sequence ${VERSION} --output json --init-required >&log.txt
141134
res=$?
142135
set +x
143-
#test $res -eq 0 || continue
144136
let rc=0
145137
for var in "$@"
146138
do
@@ -167,17 +159,10 @@ commitChaincodeDefinition() {
167159
# while 'peer chaincode' command can get the orderer endpoint from the
168160
# peer (if join was successful), let's supply it directly as we know
169161
# it using the "-o" option
170-
if [ -z "$CORE_PEER_TLS_ENABLED" -o "$CORE_PEER_TLS_ENABLED" = "false" ] ; then
171-
set -x
172-
peer lifecycle chaincode commit -o localhost:7050 --channelID $CHANNEL_NAME --name fabcar $PEER_CONN_PARMS --version ${VERSION} --sequence ${VERSION} --init-required >&log.txt
173-
res=$?
174-
set +x
175-
else
176-
set -x
177-
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
178-
res=$?
179-
set +x
180-
fi
162+
set -x
163+
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
164+
res=$?
165+
set +x
181166
cat log.txt
182167
verifyResult $res "Chaincode definition commit failed on peer0.org${ORG} on channel '$CHANNEL_NAME' failed"
183168
echo "===================== Chaincode definition committed on channel '$CHANNEL_NAME' ===================== "
@@ -225,17 +210,10 @@ chaincodeInvokeInit() {
225210
# while 'peer chaincode' command can get the orderer endpoint from the
226211
# peer (if join was successful), let's supply it directly as we know
227212
# it using the "-o" option
228-
if [ -z "$CORE_PEER_TLS_ENABLED" -o "$CORE_PEER_TLS_ENABLED" = "false" ]; then
229-
set -x
230-
peer chaincode invoke -o localhost:7050 -C $CHANNEL_NAME -n fabcar $PEER_CONN_PARMS --isInit -c '{"function":"initLedger","Args":[]}' >&log.txt
231-
res=$?
232-
set +x
233-
else
234-
set -x
235-
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
236-
res=$?
237-
set +x
238-
fi
213+
set -x
214+
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
215+
res=$?
216+
set +x
239217
cat log.txt
240218
verifyResult $res "Invoke execution on $PEERS failed "
241219
echo "===================== Invoke transaction successful on $PEERS on channel '$CHANNEL_NAME' ===================== "

test-network/scripts/envVar.sh

+8-10
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ setGlobals() {
2525
if [ -z "$OVERRIDE_ORG" ]; then
2626
USING_ORG=$1
2727
else
28-
USING_ORG="${OVERRIDE_ORG}"
28+
USING_ORG="${OVERRIDE_ORG}"
2929
fi
3030
echo "Using organization ${USING_ORG}"
3131
if [ $USING_ORG -eq 1 ]; then
@@ -54,24 +54,22 @@ setGlobals() {
5454
}
5555

5656
# parsePeerConnectionParameters $@
57-
# Helper function that takes the parameters from a chaincode operation
58-
# (e.g. invoke, query, instantiate) and checks for an even number of
59-
# peers and associated org, then sets $PEER_CONN_PARMS and $PEERS
57+
# Helper function that sets the peer connection parameters for a chaincode
58+
# operation
6059
parsePeerConnectionParameters() {
61-
# check for uneven number of peer and org parameters
6260

6361
PEER_CONN_PARMS=""
6462
PEERS=""
6563
while [ "$#" -gt 0 ]; do
6664
setGlobals $1
6765
PEER="peer0.org$1"
66+
## Set peer adresses
6867
PEERS="$PEERS $PEER"
6968
PEER_CONN_PARMS="$PEER_CONN_PARMS --peerAddresses $CORE_PEER_ADDRESS"
70-
if [ -z "$CORE_PEER_TLS_ENABLED" -o "$CORE_PEER_TLS_ENABLED" = "true" ]; then
71-
TLSINFO=$(eval echo "--tlsRootCertFiles \$PEER0_ORG$1_CA")
72-
PEER_CONN_PARMS="$PEER_CONN_PARMS $TLSINFO"
73-
fi
74-
# shift by two to get the next pair of peer/org parameters
69+
## Set path to TLS certificate
70+
TLSINFO=$(eval echo "--tlsRootCertFiles \$PEER0_ORG$1_CA")
71+
PEER_CONN_PARMS="$PEER_CONN_PARMS $TLSINFO"
72+
# shift by one to get to the next organization
7573
shift
7674
done
7775
# remove leading space for output

test-network/scripts/org3-scripts/envVarCLI.sh

-25
Original file line numberDiff line numberDiff line change
@@ -45,31 +45,6 @@ setGlobals() {
4545
fi
4646
}
4747

48-
# parsePeerConnectionParameters $@
49-
# Helper function that takes the parameters from a chaincode operation
50-
# (e.g. invoke, query, instantiate) and checks for an even number of
51-
# peers and associated org, then sets $PEER_CONN_PARMS and $PEERS
52-
parsePeerConnectionParameters() {
53-
# check for uneven number of peer and org parameters
54-
55-
PEER_CONN_PARMS=""
56-
PEERS=""
57-
while [ "$#" -gt 0 ]; do
58-
setGlobals $1
59-
PEER="peer0.org$1"
60-
PEERS="$PEERS $PEER"
61-
PEER_CONN_PARMS="$PEER_CONN_PARMS --peerAddresses $CORE_PEER_ADDRESS"
62-
if [ -z "$CORE_PEER_TLS_ENABLED" -o "$CORE_PEER_TLS_ENABLED" = "true" ]; then
63-
TLSINFO=$(eval echo "--tlsRootCertFiles \$PEER0_ORG$1_CA")
64-
PEER_CONN_PARMS="$PEER_CONN_PARMS $TLSINFO"
65-
fi
66-
# shift by two to get the next pair of peer/org parameters
67-
shift
68-
done
69-
# remove leading space for output
70-
PEERS="$(echo -e "$PEERS" | sed -e 's/^[[:space:]]*//')"
71-
}
72-
7348
verifyResult() {
7449
if [ $1 -ne 0 ]; then
7550
echo "!!!!!!!!!!!!!!! "$2" !!!!!!!!!!!!!!!!"

test-network/scripts/org3-scripts/step1org3.sh

+3-9
Original file line numberDiff line numberDiff line change
@@ -38,15 +38,9 @@ fetchChannelConfig() {
3838
setGlobals $ORG
3939

4040
echo "Fetching the most recent configuration block for the channel"
41-
if [ -z "$CORE_PEER_TLS_ENABLED" -o "$CORE_PEER_TLS_ENABLED" = "false" ]; then
42-
set -x
43-
peer channel fetch config config_block.pb -o orderer.example.com:7050 -c $CHANNEL --cafile $ORDERER_CA
44-
set +x
45-
else
46-
set -x
47-
peer channel fetch config config_block.pb -o orderer.example.com:7050 --ordererTLSHostnameOverride orderer.example.com -c $CHANNEL --tls --cafile $ORDERER_CA
48-
set +x
49-
fi
41+
set -x
42+
peer channel fetch config config_block.pb -o orderer.example.com:7050 --ordererTLSHostnameOverride orderer.example.com -c $CHANNEL --tls --cafile $ORDERER_CA
43+
set +x
5044

5145
echo "Decoding config block to JSON and isolating config to ${OUTPUT}"
5246
set -x

0 commit comments

Comments
 (0)