ocsp.test 3.4 KB

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