obsolete-server-crypto 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. #!/bin/sh
  2. #
  3. # Copyright (C) 2020 Daniel Lenski
  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. ########################################
  26. # Verify that we cannot connect to a server offering only obsolete, insecure
  27. # crypto UNLESS --allow-insecure-crypto is specified.
  28. ########################################
  29. echo "Testing against server with insecure crypto (3DES and RC4 only)..."
  30. # Run servers
  31. PORT=4568
  32. TLS_PRIORITIES="LEGACY:%SERVER_PRECEDENCE:%COMPAT:-VERS-TLS-ALL:+VERS-TLS1.0:-CIPHER-ALL:+3DES-CBC:+ARCFOUR-128:+MD5:+SHA1"
  33. update_config test-obsolete-server-crypto.config
  34. ########################################
  35. # Need to override mandatory system-wide crypto policy on Fedora 31+, in
  36. # order for ocserv to offer 3DES and RC4.
  37. #
  38. # However, we want to leave this policy in place for openconnect,
  39. # in order to verify the client's ability to disable it on its own.
  40. ########################################
  41. GNUTLS_SYSTEM_PRIORITY_FILE=/dev/null launch_simple_sr_server -d 1 -f -c $CONFIG
  42. PID=$!
  43. wait_server $PID
  44. echo -n "Connecting without --allow-insecure-crypto... "
  45. ( echo "test" | LD_PRELOAD=libsocket_wrapper.so $OPENCONNECT -q $ADDRESS:$PORT -u test --servercert=d66b507ae074d03b02eafca40d35f87dd81049d3 --cookieonly >/dev/null 2>&1) &&
  46. fail $PID "Connected successfully when we shouldn't"
  47. echo ok
  48. echo -n "Connecting with --allow-insecure-crypto... "
  49. ( echo "test" | LD_PRELOAD=libsocket_wrapper.so $OPENCONNECT -q $ADDRESS:$PORT -u test --servercert=d66b507ae074d03b02eafca40d35f87dd81049d3 --allow-insecure-crypto --cookieonly >/dev/null 2>&1) ||
  50. fail $PID "Could not connect and obtain cookie with --allow-insecure-crypto"
  51. echo ok
  52. cleanup
  53. exit 0