|
| 1 | +#!/bin/bash |
| 2 | +# test_sscep.sh |
| 3 | +# |
| 4 | +# Copyright (C) 2006-2025 wolfSSL Inc. |
| 5 | +# |
| 6 | +# This file is part of wolfProvider. |
| 7 | +# |
| 8 | +# wolfProvider is free software; you can redistribute it and/or modify |
| 9 | +# it under the terms of the GNU General Public License as published by |
| 10 | +# the Free Software Foundation; either version 3 of the License, or |
| 11 | +# (at your option) any later version. |
| 12 | +# |
| 13 | +# wolfProvider is distributed in the hope that it will be useful, |
| 14 | +# but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 15 | +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 16 | +# GNU General Public License for more details. |
| 17 | +# |
| 18 | +# You should have received a copy of the GNU General Public License |
| 19 | +# along with this program; if not, write to the Free Software |
| 20 | +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335, USA |
| 21 | +TEST_SSCEP_FAIL=0 |
| 22 | + |
| 23 | +cleanup(){ |
| 24 | + [ -f ca.crt ] && rm -f ca.crt |
| 25 | + [ -d ca-dir ] && rm -rf ca-dir |
| 26 | +} |
| 27 | + |
| 28 | +killall scepserver &> /dev/null |
| 29 | +cleanup |
| 30 | + |
| 31 | +# begin by setting up and starting the scep server |
| 32 | +OPENSSL_CONF="" OPENSSL_MODULES="" scepserver ca -depot ca-dir -init |
| 33 | +OPENSSL_CONF="" OPENSSL_MODULES="" scepserver -depot ca-dir -port 8080 -debug & |
| 34 | + |
| 35 | +sleep 1 |
| 36 | + |
| 37 | +# now test sscep |
| 38 | + |
| 39 | +# getca |
| 40 | +sscep getca -u "http://localhost:8080/scep" -c ca.crt -v -d |
| 41 | + |
| 42 | +if [ $? -eq 0 ] && [ -f ca.crt ] \ |
| 43 | + && diff -y ca.crt ca-dir/ca.pem |
| 44 | +then |
| 45 | + echo "[ PASSED ] getca" |
| 46 | +else |
| 47 | + echo "[ FAILED ] getca" |
| 48 | + TEST_SSCEP_FAIL=1 |
| 49 | +fi |
| 50 | + |
| 51 | +# getnextca |
| 52 | +# could not get certificate chaining to work. Not sure if it's the servers fault |
| 53 | +# or mine. |
| 54 | + |
| 55 | +# enroll |
| 56 | +# first generate ca request (sscep has a script for this) |
| 57 | +timeout 10 ./mkrequest -ip 1.2.3.4 |
| 58 | + |
| 59 | +if [ $? -eq 0 ]; then |
| 60 | + # then enroll -> sscep WILL fail this. |
| 61 | + # scepserver uses des-cbc (which is not supported) when sending a cert back, so |
| 62 | + # to test just check that the .csr got over to the server. This way at least |
| 63 | + # some of its functionality can be tested |
| 64 | + sscep enroll -u "http://localhost:8080/scep" -c ca.crt -k local.key -r local.csr -l local.crt -v -d |
| 65 | + |
| 66 | + if [ -f ca-dir/1.2.3.4*.pem ]; |
| 67 | + then |
| 68 | + echo "[ PASSED ] enroll" |
| 69 | + else |
| 70 | + echo "[ FAILED ] enroll" |
| 71 | + TEST_SSCEP_FAIL=1 |
| 72 | + fi |
| 73 | +else |
| 74 | + echo "[ FAILED ] enroll" |
| 75 | + TEST_SSCEP_FAIL=1 |
| 76 | +fi |
| 77 | + |
| 78 | +killall scepserver &> /dev/null |
| 79 | + |
| 80 | +cleanup |
| 81 | + |
| 82 | +$GITHUB_WORKSPACE/.github/scripts/check-workflow-result.sh $TEST_SSCEP_FAIL "$WOLFPROV_FORCE_FAIL_STR" sscep |
| 83 | +exit $? |
0 commit comments