3 ## This work is part of OpenLDAP Software <http://www.openldap.org/>.
5 ## Copyright 1998-2017 The OpenLDAP Foundation.
6 ## All rights reserved.
8 ## Redistribution and use in source and binary forms, with or without
9 ## modification, are permitted only as authorized by the OpenLDAP
12 ## A copy of this license is available in the file LICENSE in the
13 ## top-level directory of the distribution or, alternatively, at
14 ## <http://www.OpenLDAP.org/license.html>.
16 echo "running defines.sh"
17 . $SRCDIR/scripts/defines.sh
19 if test $WITH_TLS = no ; then
20 echo "TLS support not available, test skipped"
24 mkdir -p $TESTDIR $DBDIR1
25 cp -r $DATADIR/tls $TESTDIR
29 echo "Starting ldap:/// slapd on TCP/IP port $PORT1 and ldaps:/// slapd on $PORT2..."
30 . $CONFFILTER $BACKEND $MONITORDB < $TLSCONF > $CONF1
31 $SLAPD -f $CONF1 -h "$URI1 $SURI2" -d $LVL $TIMING > $LOG1 2>&1 &
33 if test $WAIT != 0 ; then
41 for i in 0 1 2 3 4 5; do
42 $LDAPSEARCH -s base -b "" -H $URI1 \
43 'objectclass=*' > /dev/null 2>&1
45 if test $RC = 0 ; then
48 echo "Waiting 5 seconds for slapd to start..."
52 if test $RC != 0 ; then
53 echo "ldapsearch failed ($RC)!"
54 test $KILLSERVERS != no && kill -HUP $KILLPIDS
58 echo -n "Using ldapsearch with startTLS with no server cert validation...."
59 $LDAPSEARCH -o tls_reqcert=never -ZZ -b "" -s base -H $URIP1 \
60 '@extensibleObject' > $SEARCHOUT 2>&1
62 if test $RC != 0 ; then
63 echo "ldapsearch (startTLS) failed ($RC)!"
69 echo -n "Using ldapsearch with startTLS with hard require cert...."
70 $LDAPSEARCH -o tls_cacert=$TESTDIR/tls/ca/certs/testsuiteCA.crt -o tls_reqcert=hard -ZZ -b "" -s base -H $URIP1 \
71 '@extensibleObject' > $SEARCHOUT 2>&1
73 if test $RC != 0 ; then
74 echo "ldapsearch (startTLS) failed ($RC)!"
80 if test $WITH_TLS_TYPE = openssl ; then
81 echo -n "Using ldapsearch with startTLS and specific protocol version...."
82 $LDAPSEARCH -o tls_cacert=$TESTDIR/tls/ca/certs/testsuiteCA.crt -o tls_reqcert=hard -o tls_protocol_min=3.3 -ZZ -b "" -s base -H $URIP1 \
83 '@extensibleObject' > $SEARCHOUT 2>&1
85 if test $RC != 0 ; then
86 echo "ldapsearch (protocol-min) failed ($RC)!"
93 echo -n "Using ldapsearch on $SURI2 with no server cert validation..."
94 $LDAPSEARCH -o tls_reqcert=never -b "cn=Subschema" -s base -H $SURIP2 \
95 '(&(objectClasses=top)(objectClasses=2.5.6.0))' cn objectClass \
98 if test $RC != 0 ; then
99 echo "ldapsearch (ldaps) failed($RC)!"
105 echo -n "Using ldapsearch on $SURI2 with reqcert HARD and no CA cert. Should fail..."
106 $LDAPSEARCH -o tls_reqcert=hard -b "cn=Subschema" -s base -H $SURIP2 \
107 '(&(objectClasses=top)(objectClasses=2.5.6.0))' cn objectClass \
110 if test $RC = 0 ; then
111 echo "ldapsearch (ldaps) succeeded when it should have failed($RC)!"
114 echo "failed correctly with error code ($RC)"
117 echo -n "Using ldapsearch on $SURI2 with CA cert and reqcert HARD..."
118 $LDAPSEARCH -o tls_cacert=$TESTDIR/tls/ca/certs/testsuiteCA.crt -o tls_reqcert=hard -b "cn=Subschema" -s base -H $SURIP2 \
119 '(&(objectClasses=top)(objectClasses=2.5.6.0))' cn objectClass \
122 if test $RC != 0 ; then
123 echo "ldapsearch (ldaps) failed ($RC)!"
129 test $KILLSERVERS != no && kill -HUP $KILLPIDS
131 if test $RC != 0 ; then
132 echo ">>>>> Test failed"
134 echo ">>>>> Test succeeded"
138 test $KILLSERVERS != no && wait