#!/bin/sh set -o nounset set -o errexit SOFTHSM=/usr/local/bin/softhsm2-util top_srcdir=$(cd $(dirname $0)/../..; pwd) . ${top_srcdir}/test/scripts/testutils.sh createca () { mkdir httpsca ( cd httpsca ; \ mkdir -p demoCA/newcerts ; \ touch demoCA/index.txt ; \ echo 00 > demoCA/serial ; \ echo '[ req ]' > caconfig.txt ; \ echo 'distinguished_name = req_distinguished_name' >> caconfig.txt ; \ echo 'x509_extensions = v3_ca' >> caconfig.txt ; \ echo 'string_mask = utf8only' >> caconfig.txt ; \ echo '[ req_distinguished_name ]' >> caconfig.txt ; \ echo '[ v3_ca ]' >> caconfig.txt ; \ echo 'basicConstraints=CA:true' >> caconfig.txt ; \ openssl req -newkey rsa:2048 -keyout key.pem -out req.csr -nodes -subj '/countryName=SE/stateOrProvinceName=Stockholm/organizationName=Test/commonName=ca/O=ca' -config caconfig.txt ; \ openssl ca -in req.csr -selfsign -keyfile key.pem -out demoCA/cacert.pem -batch \ ) } createcert () { mkdir httpscert openssl req -new -newkey rsa:2048 -keyout httpscert/httpskey-1.pem -out httpsca/httpscert-1.csr -nodes -subj '/countryName=SE/stateOrProvinceName=Stockholm/organizationName=Test/CN=localhost' ( cd httpsca ; \ openssl ca -in httpscert-1.csr -keyfile key.pem -out httpscert-1.pem -batch \ ) cp httpsca/httpscert-1.pem httpscert/ } createca createcert mkdir keys (cd keys ; ../../../tools/create-key.sh logkey) openssl pkcs8 -topk8 -nocrypt -in keys/logkey-private.pem -out keys/logkey-private.pkcs8 mkdir mergedb mkdir mergedb/chains # needed for merge_fetch worker lockfile touch mergedb/logorder mkdir mergedb-secondary touch mergedb-secondary/logorder printf 0 > mergedb-secondary/verifiedsize mkdir known_roots cp ../../tools/testcerts/roots/* known_roots for machine in ${MACHINES}; do \ ../../tools/compileconfig.py --config ../../test/catlfish-test.cfg --localconfig ../../test/catlfish-test-local-${machine}.cfg mkdir -p machine/machine-${machine}/db touch machine/machine-${machine}/db/index && touch machine/machine-${machine}/db/newentries done ../../tools/compileconfig.py --config ../../test/catlfish-test.cfg --localconfig ../../test/catlfish-test-local-merge-2.cfg ../../tools/compileconfig.py --config ../../test/catlfish-test.cfg --localconfig ../../test/catlfish-test-local-signing.cfg mkdir privatekeys mkdir publickeys for node in ${NODES}; do \ (cd privatekeys ; ../../../tools/create-key.sh ${node}) ; \ mv privatekeys/${node}.pem publickeys/ ; \ mkdir -p nodes/${node}/log done (cd privatekeys ; ../../../tools/create-key.sh merge-1) mv privatekeys/merge-1.pem publickeys/ (cd privatekeys ; ../../../tools/create-key.sh merge-2) mv privatekeys/merge-2.pem publickeys/ test -x ${SOFTHSM} && ${SOFTHSM} --init-token --slot=0 --label=mylabel --so-pin=ffff --pin=ffff || true test -x ${SOFTHSM} && ${SOFTHSM} --import keys/logkey-private.pkcs8 --slot 0 --label mylabel --pin ffff --id 00 || true