external.test 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. #!/bin/bash
  2. # external.test
  3. SCRIPT_DIR="$(dirname "$0")"
  4. server=www.wolfssl.com
  5. ca=./certs/wolfssl-website-ca.pem
  6. [ ! -x ./examples/client/client ] && echo -e "\n\nClient doesn't exist" && exit 1
  7. # www.wolfssl.com isn't using RFC 8446 yet but the draft instead.
  8. if ! ./examples/client/client -V | grep -q 3; then
  9. echo 'skipping external.test because TLS1.2 is not available.' 1>&2
  10. exit 77
  11. fi
  12. # cloudflare seems to change CAs quickly, disabled by default
  13. if test -n "$WOLFSSL_EXTERNAL_TEST"; then
  14. BUILD_FLAGS="$(./examples/client/client '-#')"
  15. if echo "$BUILD_FLAGS" | fgrep -q -e ' -DWOLFSSL_SNIFFER '; then
  16. echo 'skipping WOLFSSL_EXTERNAL_TEST because -DWOLFSSL_SNIFFER configuration of build is incompatible.'
  17. exit 77
  18. fi
  19. if echo "$BUILD_FLAGS" | fgrep -v -q -e ' -DHAVE_ECC '; then
  20. echo 'skipping WOLFSSL_EXTERNAL_TEST because -UHAVE_ECC configuration of build is incompatible.'
  21. exit 77
  22. fi
  23. echo "WOLFSSL_EXTERNAL_TEST set, running test..."
  24. else
  25. echo "WOLFSSL_EXTERNAL_TEST NOT set, won't run"
  26. exit 77
  27. fi
  28. # is our desired server there?
  29. "${SCRIPT_DIR}"/ping.test $server 2
  30. RESULT=$?
  31. [ $RESULT -ne 0 ] && exit 0
  32. # client test against the server
  33. ./examples/client/client -X -C -h $server -p 443 -g -A $ca
  34. RESULT=$?
  35. [ $RESULT -ne 0 ] && echo -e "\n\nClient connection failed" && exit 1
  36. # test again, but using system CA certs to verify the server if support is enabled.
  37. # We don't want to use --sys-ca-certs with static memory, as we don't know how
  38. # much memory will be required to store an unbounded number of certs
  39. BUILD_FLAGS="$(./examples/client/client '-#')"
  40. if echo "$BUILD_FLAGS" | grep -q "WOLFSSL_SYS_CA_CERTS" && ! echo "$BUILD_FLAGS" | grep -q "WOLFSSL_STATIC_MEMORY"; then
  41. echo -e "\nConnecting using WOLFSSL_SYS_CA_CERTS..."
  42. ./examples/client/client -X -C -h $server -p 443 -g --sys-ca-certs
  43. RESULT=$?
  44. [ $RESULT -ne 0 ] && echo -e "\n\nClient connection failed when using WOLFSSL_SYS_CA_CERTS" && exit 1
  45. fi
  46. exit 0