Skip to content

Commit

Permalink
FABN-1176: Fix Mac crypto generation scripts
Browse files Browse the repository at this point in the history
Change-Id: I366316a02dd5b7d063c714693c5218c6b6a15682
Signed-off-by: Mark S. Lewis <[email protected]>
  • Loading branch information
bestbeforetoday committed Mar 12, 2019
1 parent e2fd26c commit 44a8b17
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 33 deletions.
3 changes: 1 addition & 2 deletions build/tasks/certs.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,7 @@ gulp.task('get-crypto-binaries-amd64', shell.task(
);

gulp.task('get-crypto-binaries-mac', shell.task(
'mkdir -p ' + binariesPath + ';' +
'wget ' + darwinBinaries + ' -P ' + binariesPath + ';' +
'curl --create-dirs --output ' + binariesPath + '/' + darwinTarFile + ' ' + darwinBinaries + ';' +
'tar xvzf ' + binariesPath + '/' + darwinTarFile + ' -C ' + binariesPath + ';')
);

Expand Down
38 changes: 19 additions & 19 deletions test/fixtures/crypto-material/config-base/generate.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,34 +4,34 @@
#

# Set the path to teh crypto material to ensure it may be used
CRYPTOGEN=$1
export PATH=${PATH}:${CRYPTOGEN}
CRYPTOGEN="$1"
export PATH="${PATH}:${CRYPTOGEN}"

# Get current location to ensure things go to the correct place
BASEDIR=$(dirname $(realpath $0))
BASEDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"

# Start generating
echo "Creating new crypto material and tx blocks from within directory ${BASEDIR}"
rm -rf ${BASEDIR}/../crypto-config
rm -rf ${BASEDIR}/../channel-config
mkdir ${BASEDIR}/../crypto-config
mkdir ${BASEDIR}/../channel-config
rm -rf "${BASEDIR}/../crypto-config"
rm -rf "${BASEDIR}/../channel-config"
mkdir "${BASEDIR}/../crypto-config"
mkdir "${BASEDIR}/../channel-config"

echo 'Generating base crypto-material and channel tx files....'
export FABRIC_CFG_PATH=${BASEDIR}
cryptogen generate --config=${BASEDIR}/crypto-config.yaml --output=${BASEDIR}/../crypto-config
configtxgen -profile TwoOrgsOrdererGenesis -outputBlock ${BASEDIR}/twoorgs.genesis.block
configtxgen -profile TwoOrgsChannel -outputCreateChannelTx ${BASEDIR}/../channel-config/mychannel.tx -channelID mychannel
configtxgen -profile TwoOrgsChannel -outputCreateChannelTx ${BASEDIR}/../channel-config/mychannel2.tx -channelID mychannel2 #test/integration/network-config.js
configtxgen -profile TwoOrgsChannel -outputCreateChannelTx ${BASEDIR}/../channel-config/mychanneltx.tx -channelID mychanneltx #test/integration/create-configtx-channel.js
configtxgen -profile TwoOrgsChannel -outputCreateChannelTx ${BASEDIR}/../channel-config/mychannelts.tx -channelID mychannelts #test/typescript
configtxgen -profile TwoOrgsChannel -outputCreateChannelTx ${BASEDIR}/../channel-config/adminconfig.tx -channelID adminconfig #test/only-admin.js
configtxgen -profile TwoOrgsChannel -outputCreateChannelTx ${BASEDIR}/../channel-config/discovery.tx -channelID discovery #test/integration/discovery.js
export FABRIC_CFG_PATH="${BASEDIR}"
cryptogen generate --config="${BASEDIR}/crypto-config.yaml" --output="${BASEDIR}/../crypto-config"
configtxgen -profile TwoOrgsOrdererGenesis -outputBlock "${BASEDIR}/twoorgs.genesis.block"
configtxgen -profile TwoOrgsChannel -outputCreateChannelTx "${BASEDIR}/../channel-config/mychannel.tx" -channelID mychannel
configtxgen -profile TwoOrgsChannel -outputCreateChannelTx "${BASEDIR}/../channel-config/mychannel2.tx" -channelID mychannel2 #test/integration/network-config.js
configtxgen -profile TwoOrgsChannel -outputCreateChannelTx "${BASEDIR}/../channel-config/mychanneltx.tx" -channelID mychanneltx #test/integration/create-configtx-channel.js
configtxgen -profile TwoOrgsChannel -outputCreateChannelTx "${BASEDIR}/../channel-config/mychannelts.tx" -channelID mychannelts #test/typescript
configtxgen -profile TwoOrgsChannel -outputCreateChannelTx "${BASEDIR}/../channel-config/adminconfig.tx" -channelID adminconfig #test/only-admin.js
configtxgen -profile TwoOrgsChannel -outputCreateChannelTx "${BASEDIR}/../channel-config/discovery.tx" -channelID discovery #test/integration/discovery.js

echo 'Generating crypto-material complete, now renaming keys...'
# Rename the key files we use to be key.pem instead of a uuid
for KEY in $(find ${BASEDIR}/../crypto-config -type f -name "*_sk"); do
KEY_DIR=$(dirname ${KEY})
mv ${KEY} ${KEY_DIR}/key.pem
for KEY in $(find "${BASEDIR}/../crypto-config" -type f -name "*_sk"); do
KEY_DIR="$(dirname ${KEY})"
mv ${KEY} "${KEY_DIR}/key.pem"
done
echo 'Renaming keys complete'
12 changes: 6 additions & 6 deletions test/fixtures/crypto-material/config-update/generate.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@
#

# Set the path to teh crypto material to ensure it may be used
CRYPTOGEN=$1
export PATH=${PATH}:${CRYPTOGEN}
CRYPTOGEN="$1"
export PATH="${PATH}:${CRYPTOGEN}"

# Get current location to ensure things go to the correct place
BASEDIR=$(dirname $(realpath $0))
BASEDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"

echo
echo "Creating new channel update tx blocks from within directory ${BASEDIR}"
export FABRIC_CFG_PATH=$BASEDIR
configtxgen -profile TwoOrgsChannel -outputAnchorPeersUpdate ${BASEDIR}/../channel-config/mychannel-org1anchor.tx -channelID mychannel -asOrg Org1MSP
configtxgen -profile TwoOrgsChannel -outputAnchorPeersUpdate ${BASEDIR}/../channel-config/discovery_anchor.tx -channelID discovery -asOrg Org1MSP
export FABRIC_CFG_PATH="$BASEDIR"
configtxgen -profile TwoOrgsChannel -outputAnchorPeersUpdate "${BASEDIR}/../channel-config/mychannel-org1anchor.tx" -channelID mychannel -asOrg Org1MSP
configtxgen -profile TwoOrgsChannel -outputAnchorPeersUpdate "${BASEDIR}/../channel-config/discovery_anchor.tx" -channelID discovery -asOrg Org1MSP

6 changes: 3 additions & 3 deletions test/fixtures/crypto-material/generateAll.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ CRYPTOGEN=$1
echo ''
echo "Crypto-gen scripts running based on binaries location ${CRYPTOGEN}"

BASEDIR=$(dirname $(realpath $0))
${BASEDIR}/config-base/generate.sh ${CRYPTOGEN}
${BASEDIR}/config-update/generate.sh ${CRYPTOGEN}
BASEDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
"${BASEDIR}/config-base/generate.sh" ${CRYPTOGEN}
"${BASEDIR}/config-update/generate.sh" ${CRYPTOGEN}

echo ''
10 changes: 7 additions & 3 deletions test/fixtures/fabricca/generateCSR.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
#!/bin/bash
#
# SPDX-License-Identifier: Apache-2.0
#

BASEDIR=$(dirname $(realpath $0))
BASEDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
echo "Generating fabricca cetificates and keys in directory ${BASEDIR}"
openssl req -nodes -newkey rsa:2048 -keyout ${BASEDIR}/test.key -out ${BASEDIR}/test.csr -subj "/C=GB/ST=London/L=London/O=Global Security/OU=IT Department/CN=aTestUser"
openssl req -nodes -newkey rsa:512 -keyout ${BASEDIR}/enroll-key.pem -out ${BASEDIR}/enroll-csr.pem -subj "/C=GB/ST=London/L=London/O=Global Security/OU=IT Department/CN=testUser"
openssl req -nodes -newkey rsa:2048 -keyout "${BASEDIR}/test.key" -out "${BASEDIR}/test.csr" -subj "/C=GB/ST=London/L=London/O=Global Security/OU=IT Department/CN=aTestUser"
openssl req -nodes -newkey rsa:512 -keyout "${BASEDIR}/enroll-key.pem" -out "${BASEDIR}/enroll-csr.pem" -subj "/C=GB/ST=London/L=London/O=Global Security/OU=IT Department/CN=testUser"
echo "Generation complete"

0 comments on commit 44a8b17

Please sign in to comment.