ocsp.test 3.4 KB

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