pfs 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  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 RSA key exchange
  27. # IF --pfs is specified to require perfect forward secrecy, but that we
  28. # CAN connect if it is not specified.
  29. ########################################
  30. echo "Testing against server without PFS..."
  31. # Need to disable TLS 1.3 here because GnuTLS v3.6.13 is allowing non-RSA KX with TLS 1.3, even with -KX-ALL
  32. # But can't use -VERS-TLS1.3 here, because it's not known to earlier versions of GnuTLS.
  33. PORT=4569
  34. TLS_PRIORITIES="LEGACY:%SERVER_PRECEDENCE:%COMPAT:-VERS-TLS-ALL:+VERS-TLS1.0:+VERS-TLS1.1:+VERS-TLS1.2:-KX-ALL:+RSA"
  35. update_config test-obsolete-server-crypto.config
  36. launch_simple_sr_server -d 1 -f -c $CONFIG
  37. PID=$!
  38. wait_server $PID
  39. echo -n "Connecting with --pfs... "
  40. ( echo "test" | LD_PRELOAD=libsocket_wrapper.so $OPENCONNECT -q $ADDRESS:$PORT -u test --servercert=d66b507ae074d03b02eafca40d35f87dd81049d3 --pfs --cookieonly >/dev/null 2>&1) &&
  41. fail $PID "Connected successfully when we shouldn't"
  42. echo ok
  43. echo -n "Connecting without --pfs... "
  44. ( echo "test" | LD_PRELOAD=libsocket_wrapper.so $OPENCONNECT -q $ADDRESS:$PORT -u test --servercert=d66b507ae074d03b02eafca40d35f87dd81049d3 --cookieonly >/dev/null 2>&1) ||
  45. fail $PID "Could not connect and obtain cookie without --pfs"
  46. echo ok
  47. cleanup
  48. exit 0