test_axssl.sh 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163
  1. #!/bin/sh
  2. #
  3. # Copyright (c) 2007, Cameron Rich
  4. #
  5. # All rights reserved.
  6. #
  7. # Redistribution and use in source and binary forms, with or without
  8. # modification, are permitted provided that the following conditions are met:
  9. #
  10. # * Redistributions of source code must retain the above copyright notice,
  11. # this list of conditions and the following disclaimer.
  12. # * Redistributions in binary form must reproduce the above copyright
  13. # notice, this list of conditions and the following disclaimer in the
  14. # documentation and/or other materials provided with the distribution.
  15. # * Neither the name of the axTLS project nor the names of its
  16. # contributors may be used to endorse or promote products derived
  17. # from this software without specific prior written permission.
  18. #
  19. # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  20. # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  21. # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
  22. # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
  23. # CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  24. # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
  25. # TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
  26. # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
  27. # OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
  28. # NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
  29. # THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  30. #
  31. #
  32. # Test the various axssl bindings. To run it, got to the _install directory
  33. # and run this script from there.
  34. #
  35. if grep "CONFIG_PLATFORM_WIN32=y" "../config/.config" > /dev/null; then
  36. JAVA_EXE="$JAVA_HOME/bin/java.exe"
  37. PERL_BIN="/cygdrive/c/Perl/bin/perl"
  38. KILL_AXSSL="kill %1"
  39. KILL_CSHARP="kill %1"
  40. KILL_PERL="kill %1"
  41. KILL_JAVA="kill %1"
  42. KILL_LUA="kill %1"
  43. else
  44. if grep "CONFIG_PLATFORM_CYGWIN=y" "../config/.config" > /dev/null; then
  45. # no .net or java on cygwin
  46. PERL_BIN=/usr/bin/perl
  47. KILL_AXSSL="killall axssl"
  48. KILL_PERL="killall /usr/bin/perl"
  49. KILL_LUA="killall /usr/local/bin/lua"
  50. else # Linux
  51. JAVA_EXE=/usr/java/default/bin/java
  52. PERL_BIN=/usr/bin/perl
  53. KILL_AXSSL="killall axssl"
  54. KILL_CSHARP="killall mono"
  55. KILL_PERL="killall /usr/bin/perl"
  56. RUN_CSHARP="mono"
  57. KILL_JAVA="killall $JAVA_EXE"
  58. KILL_LUA="killall /usr/local/bin/lua"
  59. fi
  60. fi
  61. BASE=..
  62. SERVER_ARGS="s_server -accept 15001 -verify -CAfile $BASE/ssl/test/axTLS.ca_x509.cer"
  63. CLIENT_ARGS="s_client -reconnect -connect localhost:15001 -verify -CAfile $BASE/ssl/test/axTLS.ca_x509.cer -key $BASE/ssl/test/axTLS.key_1024 -cert $BASE/ssl/test/axTLS.x509_1024.cer"
  64. # check pem arguments
  65. SERVER_PEM_ARGS="s_server -accept 15001 -pass abcd -key $BASE/ssl/test/axTLS.key_aes128.pem -cert $BASE/ssl/test/axTLS.x509_aes128.pem"
  66. CLIENT_PEM_ARGS="s_client -connect localhost:15001 -CAfile $BASE/ssl/test/axTLS.ca_x509.pem -key $BASE/ssl/test/axTLS.key_1024.pem -cert $BASE/ssl/test/axTLS.x509_1024.pem"
  67. export LD_LIBRARY_PATH=.:`perl -e 'use Config; print $Config{archlib};'`/CORE
  68. if [ -x ./axssl ]; then
  69. echo "############################# C SAMPLE ###########################"
  70. ./axssl $SERVER_ARGS &
  71. echo "C Test passed" | ./axssl $CLIENT_ARGS
  72. $KILL_AXSSL
  73. sleep 1
  74. ./axssl $SERVER_PEM_ARGS &
  75. echo "C Test passed" | ./axssl $CLIENT_PEM_ARGS
  76. $KILL_AXSSL
  77. sleep 1
  78. echo "### C tests complete"
  79. fi
  80. if [ -f ./axtls.jar ]; then
  81. echo "########################## JAVA SAMPLE ###########################"
  82. "$JAVA_EXE" -jar ./axtls.jar $SERVER_ARGS &
  83. echo "Java Test passed" | "$JAVA_EXE" -jar ./axtls.jar $CLIENT_ARGS
  84. $KILL_JAVA
  85. sleep 1
  86. "$JAVA_EXE" -jar ./axtls.jar $SERVER_PEM_ARGS &
  87. echo "Java Test passed" | "$JAVA_EXE" -jar ./axtls.jar $CLIENT_PEM_ARGS
  88. $KILL_JAVA
  89. sleep 1
  90. echo "### Java tests complete"
  91. fi
  92. if [ -x ./axssl.csharp.exe ]; then
  93. echo "############################ C# SAMPLE ###########################"
  94. $RUN_CSHARP ./axssl.csharp.exe $SERVER_ARGS &
  95. echo "C# Test passed" | $RUN_CSHARP ./axssl.csharp.exe $CLIENT_ARGS
  96. $KILL_CSHARP
  97. sleep 1
  98. $RUN_CSHARP ./axssl.csharp.exe $SERVER_PEM_ARGS &
  99. echo "C# Test passed" | $RUN_CSHARP ./axssl.csharp.exe $CLIENT_PEM_ARGS
  100. $KILL_CSHARP
  101. sleep 1
  102. echo "### C# tests complete"
  103. fi
  104. if [ -x ./axssl.vbnet.exe ]; then
  105. echo "######################## VB.NET SAMPLE ###########################"
  106. echo $SERVER_ARGS
  107. echo $CLIENT_ARGS
  108. ./axssl.vbnet $SERVER_ARGS &
  109. echo "VB.NET Test passed" | ./axssl.vbnet.exe $CLIENT_ARGS
  110. kill %1
  111. sleep 1
  112. ./axssl.vbnet $SERVER_PEM_ARGS &
  113. echo "VB.NET Test passed" | ./axssl.vbnet.exe $CLIENT_PEM_ARGS
  114. kill %1
  115. sleep 1
  116. echo "### VB.NET tests complete"
  117. fi
  118. if [ -f ./axssl.pl ]; then
  119. echo "########################## PERL SAMPLE ###########################"
  120. "$PERL_BIN" ./axssl.pl $SERVER_ARGS &
  121. echo "Perl Test passed" | "$PERL_BIN" ./axssl.pl $CLIENT_ARGS
  122. $KILL_PERL
  123. sleep 1
  124. "$PERL_BIN" ./axssl.pl $SERVER_PEM_ARGS &
  125. echo "Perl Test passed" | "$PERL_BIN" ./axssl.pl $CLIENT_PEM_ARGS
  126. $KILL_PERL
  127. sleep 1
  128. echo "### Perl tests complete"
  129. fi
  130. if [ -f ./axssl.lua ]; then
  131. echo "########################## LUA SAMPLE ###########################"
  132. ./axssl.lua $SERVER_ARGS &
  133. echo "Lua Test passed" | ./axssl.lua $CLIENT_ARGS
  134. $KILL_LUA
  135. sleep 1
  136. ./axssl.lua $SERVER_PEM_ARGS &
  137. echo "Lua Test passed" | ./axssl.lua $CLIENT_PEM_ARGS
  138. $KILL_LUA
  139. sleep 1
  140. echo "### Lua tests complete"
  141. fi
  142. echo "########################## ALL TESTS COMPLETE ###########################"