From 057d38ee7625060261919dee49c4b5207a41f534 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Trojnara?= Date: Sun, 27 Jun 2021 10:10:01 +0200 Subject: [PATCH] Additional test dependency checks --- tests/testall.sh | 2 +- tests/testsign.sh | 45 ++++++++++++++++++++++++++++++--------------- 2 files changed, 31 insertions(+), 16 deletions(-) diff --git a/tests/testall.sh b/tests/testall.sh index 21895ad..8a285b2 100755 --- a/tests/testall.sh +++ b/tests/testall.sh @@ -87,7 +87,7 @@ if grep -q "no libgsf available" "results.log" rm -f "FoobarAppl10.exe" else printf "%s\n" "wixl not found in \$PATH" - printf "%s\n" "tests for MSI files skipped, please install msitools package" + printf "%s\n" "tests for MSI files skipped, please install wixl or msitools package depending on your OS" fi fi diff --git a/tests/testsign.sh b/tests/testsign.sh index bff3fe0..21b34f1 100755 --- a/tests/testsign.sh +++ b/tests/testsign.sh @@ -1,5 +1,11 @@ #!/bin/sh +if [ -z "$(command -v keytool)" ]; then + printf "%s\n" "keytool was not found in the \$PATH" + printf "%s\n" "Please install the default-jre-headless package" + exit 1 +fi + rm -f putty*.exe PUTTY_URL="http://the.earth.li/~sgtatham/putty/0.64/x86/putty.exe" @@ -14,7 +20,12 @@ fi rm -f cert.pem cert.spc key.der key.p12 key.pem key.pvk keyp.pem keytool -genkey \ - -alias selfsigned -keysize 2048 -keyalg RSA -keypass passme -storepass passme -keystore key.ks << EOF + -alias selfsigned \ + -keysize 2048 \ + -keyalg RSA \ + -keypass passme \ + -storepass passme \ + -keystore key.ks << EOF John Doe ACME In ACME @@ -24,11 +35,17 @@ SE yes EOF - echo "Converting key/cert to PKCS12 container" keytool -importkeystore \ - -srckeystore key.ks -srcstoretype JKS -srckeypass passme -srcstorepass passme -srcalias selfsigned \ - -destkeystore key.p12 -deststoretype PKCS12 -destkeypass passme -deststorepass passme + -srckeystore key.ks \ + -srcstoretype JKS \ + -srckeypass passme \ + -srcstorepass passme \ + -srcalias selfsigned \ + -destkeystore key.p12 \ + -deststoretype PKCS12 \ + -destkeypass passme \ + -deststorepass passme rm -f key.ks @@ -46,7 +63,7 @@ openssl pkcs12 -in key.p12 -passin pass:passme -nokeys -out cert.pem echo "Converting cert to SPC format" openssl crl2pkcs7 -nocrl -certfile cert.pem -outform DER -out cert.spc - +make -C .. ../osslsigncode sign -spc cert.spc -key key.pem putty.exe putty1.exe ../osslsigncode sign -certs cert.spc -key keyp.pem -pass passme putty.exe putty2.exe ../osslsigncode sign -certs cert.pem -key keyp.pem -pass passme putty.exe putty3.exe @@ -56,20 +73,18 @@ openssl crl2pkcs7 -nocrl -certfile cert.pem -outform DER -out cert.spc rm -f cert.pem cert.spc key.der key.p12 key.pem key.pvk keyp.pem -echo "" -echo "" +echo check=`sha1sum putty[1-9]*.exe | cut -d' ' -f1 | uniq | wc -l` cmp putty1.exe putty2.exe && \ - cmp putty2.exe putty3.exe && \ - cmp putty3.exe putty4.exe && \ - cmp putty4.exe putty5.exe && \ - cmp putty5.exe putty6.exe + cmp putty2.exe putty3.exe && \ + cmp putty3.exe putty4.exe && \ + cmp putty4.exe putty5.exe && \ + cmp putty5.exe putty6.exe if [ $? -ne 0 ]; then - echo "Failure is not an option." - exit 1 + echo "Failure is not an option." + exit 1 else - echo "Yes, it works." + echo "Yes, it works." fi -