id-test 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. #!/bin/sh
  2. #
  3. # Copyright © 2016 Red Hat, Inc.
  4. #
  5. # This file is part of openconnect.
  6. #
  7. # This is free software; you can redistribute it and/or
  8. # modify it under the terms of the GNU Lesser General Public License
  9. # as published by the Free Software Foundation; either version 2.1 of
  10. # the License, or (at your option) any later version.
  11. #
  12. # This library is distributed in the hope that it will be useful, but
  13. # WITHOUT ANY WARRANTY; without even the implied warranty of
  14. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  15. # Lesser General Public License for more details.
  16. #
  17. # You should have received a copy of the GNU Lesser General Public License
  18. # along with this program. If not, see <http://www.gnu.org/licenses/>
  19. # This test uses LD_PRELOAD
  20. PRELOAD=1
  21. SERV="${SERV:-../src/ocserv}"
  22. srcdir=${srcdir:-.}
  23. top_builddir=${top_builddir:-..}
  24. . `dirname $0`/common.sh
  25. echo "Testing certificate auth..."
  26. launch_simple_sr_server -d 1 -f -c configs/test-user-pass.config >/dev/null 2>&1
  27. PID=$!
  28. wait_server $PID
  29. echo -n "Connecting with legacy hash... "
  30. ( echo "test" | LD_PRELOAD=libsocket_wrapper.so $OPENCONNECT -q $ADDRESS:443 -u test --servercert=d66b507ae074d03b02eafca40d35f87dd81049d3 --cookieonly >/dev/null 2>&1) ||
  31. fail $PID "Could not receive cookie from server"
  32. echo ok
  33. echo -n "Connecting with SHA1 ID... "
  34. ( echo "test" | LD_PRELOAD=libsocket_wrapper.so $OPENCONNECT -q $ADDRESS:443 -u test --servercert=sha1:a82547f68f44d6351bef6cacd1d7b96e84f9dfa3 --cookieonly >/dev/null 2>&1) ||
  35. fail $PID "Could not receive cookie from server"
  36. echo ok
  37. echo -n "Connecting with SHA256 ID... "
  38. ( echo "test" | LD_PRELOAD=libsocket_wrapper.so $OPENCONNECT -q $ADDRESS:443 -u test --servercert=sha256:c69dec71fcf2deb390b2ff4d70ebdeffc61556ffa91ebe2a3425c45eb365e6cf --cookieonly >/dev/null 2>&1) ||
  39. fail $PID "Could not receive cookie from server"
  40. echo ok
  41. echo -n "Connecting with SHA256 partial ID... "
  42. ( echo "test" | LD_PRELOAD=libsocket_wrapper.so $OPENCONNECT -q $ADDRESS:443 -u test --servercert=sha256:c69dec --cookieonly >/dev/null 2>&1) ||
  43. fail $PID "Could not receive cookie from server"
  44. echo ok
  45. echo -n "Connecting with wrong SHA256 ID... "
  46. ( echo "test" | LD_PRELOAD=libsocket_wrapper.so $OPENCONNECT -q $ADDRESS:443 -u test --servercert=sha256:c69ded --cookieonly >/dev/null 2>&1) &&
  47. fail $PID "Did connect to the server with wrong ID"
  48. echo ok
  49. cleanup
  50. exit 0