2
0

ocsp.test 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. #!/bin/sh
  2. # ocsp.test
  3. # Note, this script makes connection(s) to the public Internet.
  4. SCRIPT_DIR="$(dirname "$0")"
  5. server=www.globalsign.com
  6. ca=certs/external/ca-globalsign-root.pem
  7. [ ! -x ./examples/client/client ] && printf '\n\n%s\n' "Client doesn't exist" \
  8. && exit 1
  9. ./examples/client/client -v 3 2>&1 | grep -- 'Bad SSL version'
  10. if [ $? -eq 0 ]; then
  11. echo "TLS 1.2 or lower required"
  12. echo "Skipped"
  13. exit 0
  14. fi
  15. GL_UNREACHABLE=0
  16. # Global Sign now requires server name indication extension to work, check
  17. # enabled prior to testing
  18. OUTPUT=$(eval "./examples/client/client -S check")
  19. if [ "$OUTPUT" = "SNI is: ON" ]; then
  20. printf '\n\n%s\n\n' "SNI is on, proceed with globalsign test"
  21. # is our desired server there?
  22. ${SCRIPT_DIR}/ping.test $server 2
  23. RESULT=$?
  24. if [ $RESULT -ne 0 ]; then
  25. GL_UNREACHABLE=1
  26. fi
  27. if [ $RESULT -eq 0 ]; then
  28. # client test against the server
  29. ./examples/client/client -X -C -h $server -p 443 -A $ca -g -o -N -v d -S $server
  30. GL_RESULT=$?
  31. [ $GL_RESULT -ne 0 ] && printf '\n\n%s\n' "Client connection failed"
  32. else
  33. GL_RESULT=1
  34. fi
  35. else
  36. printf '\n\n%s\n\n' "SNI disabled, skipping globalsign test"
  37. GL_RESULT=0
  38. fi
  39. server=www.google.com
  40. ca=${SCRIPT_DIR}/../certs/external/ca-google-root.pem
  41. # is our desired server there?
  42. ${SCRIPT_DIR}/ping.test $server 2
  43. RESULT=$?
  44. if [ $RESULT -eq 0 ]; then
  45. # client test against the server
  46. ./examples/client/client -X -C -h $server -p 443 -A $ca -g -o -N
  47. GR_RESULT=$?
  48. [ $GR_RESULT -ne 0 ] && printf '\n\n%s\n' "Client connection failed"
  49. else
  50. GR_RESULT=1
  51. fi
  52. if test -n "$WOLFSSL_OCSP_TEST"; then
  53. # check that both passed
  54. if [ $GL_RESULT -eq 0 ] && [ $GR_RESULT -eq 0 ]; then
  55. printf '\n\n%s\n' "Both OCSP connection to globalsign and google passed"
  56. printf '%s\n' "Test Passed!"
  57. exit 0
  58. elif [ $GL_UNREACHABLE -eq 1 ] && [ $GR_RESULT -eq 0 ]; then
  59. printf '%s\n' "Global Sign is currently unreachable. Logging it but if"
  60. printf '%s\n' "this continues to occur should be investigated"
  61. exit 0
  62. else
  63. # Unlike other environment variables the intent of WOLFSSL_OCSP_TEST
  64. # is to indicate a requirement for both tests to pass. If variable is
  65. # set and either tests fail then whole case fails. Do not set the
  66. # variable if either case passing is to be considered a success.
  67. printf '\n\n%s\n' "One of the OCSP connections to either globalsign or"
  68. printf '%s\n' "google failed, however since WOLFSSL_OCSP_TEST is set"
  69. printf '%s\n' "the test is considered to have failed"
  70. printf '%s\n' "Test Failed!"
  71. exit 1
  72. fi
  73. else
  74. # if environment variable is not set then just need one to pass
  75. if [ $GL_RESULT -ne 0 ] && [ $GR_RESULT -ne 0 ]; then
  76. printf '\n\n%s\n' "Both OCSP connection to globalsign and google failed"
  77. printf '%s\n' "Test Failed!"
  78. exit 1
  79. else
  80. printf '\n\n%s\n' "WOLFSSL_OCSP_TEST NOT set, and 1 of the tests passed"
  81. printf '%s\n' "Test Passed!"
  82. exit 0
  83. fi
  84. fi