ocsp.test 3.0 KB

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