auth-pkcs11 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. #!/bin/sh
  2. #
  3. # Copyright (C) 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. pkcs11_keys=${pkcs11_keys:-object=RSA object=DSA object=EC id=%01 id=%02 id=%03}
  26. pkcs11_tokens=${pkcs11_tokens:-openconnect-test}
  27. echo "Testing PKCS#11 auth..."
  28. launch_simple_sr_server -d 1 -f -c configs/test-user-cert.config
  29. PID=$!
  30. wait_server $PID
  31. for TOKEN in ${pkcs11_tokens}; do
  32. for KEY in ${pkcs11_keys}; do
  33. echo -n "Connecting to obtain cookie (token ${TOKEN} key ${KEY})... "
  34. CERTURI="pkcs11:token=${TOKEN};${KEY};pin-value=1234"
  35. ( echo "test" | SOFTHSM2_CONF=softhsm2.conf LD_PRELOAD=libsocket_wrapper.so \
  36. $OPENCONNECT -q $ADDRESS:443 -u test -c "${CERTURI}" --key-password 1234 --servercert=d66b507ae074d03b02eafca40d35f87dd81049d3 --cookieonly --passwd-on-stdin ) ||
  37. fail $PID "Could not connect with token ${TOKEN} key ${KEY##*/}!"
  38. done
  39. done
  40. echo ok
  41. cleanup
  42. exit 0