auth-multicert 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. #!/bin/sh
  2. #
  3. # Copyright © 2021 Daniel Lenski
  4. # Copyright © 2021 Tom Carroll
  5. #
  6. # This file is part of openconnect.
  7. #
  8. # This is free software; you can redistribute it and/or
  9. # modify it under the terms of the GNU Lesser General Public License
  10. # as published by the Free Software Foundation; either version 2.1 of
  11. # the License, or (at your option) any later version.
  12. #
  13. # This library is distributed in the hope that it will be useful, but
  14. # WITHOUT ANY WARRANTY; without even the implied warranty of
  15. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  16. # Lesser General Public License for more details.
  17. #
  18. # You should have received a copy of the GNU Lesser General Public License
  19. # along with this program. If not, see <http://www.gnu.org/licenses/>
  20. # This test uses LD_PRELOAD
  21. PRELOAD=1
  22. srcdir=${srcdir:-.}
  23. top_builddir=${top_builddir:-..}
  24. . `dirname $0`/common.sh
  25. FINGERPRINT="--servercert=d66b507ae074d03b02eafca40d35f87dd81049d3"
  26. CERT=$certdir/server-cert.pem
  27. KEY=$certdir/server-key.pem
  28. USERCERT=$certdir/user-cert.pem
  29. USERKEY=$certdir/user-key-pkcs1.pem
  30. CAFILE=$certdir/ca.pem
  31. echo "Testing multiple certificate authentication against fake Cisco server ... "
  32. OCSERV=${srcdir}/fake-cisco-server.py
  33. launch_simple_sr_server --enable-multicert --cafile $CAFILE $ADDRESS 443 $CERT $KEY > /dev/null 2>&1
  34. PID=$!
  35. wait_server $PID
  36. echo -n "Authenticating using multiple certificate authentication... "
  37. ( echo "test" | LD_PRELOAD=libsocket_wrapper.so $OPENCONNECT --cafile $CAFILE \
  38. --certificate $USERCERT --sslkey $USERKEY \
  39. --mca-certificate $USERCERT --mca-key $USERKEY \
  40. -q $ADDRESS:443 $FINGERPRINT --authenticate >/dev/null 2>&1) ||
  41. fail $PID "Could not receive cookie from fake Cisco server"
  42. echo ok
  43. cleanup
  44. exit 0