ocsp.test 3.0 KB

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