diff options
author | Damien Miller <djm@cvs.openbsd.org> | 2010-03-03 00:47:24 +0000 |
---|---|---|
committer | Damien Miller <djm@cvs.openbsd.org> | 2010-03-03 00:47:24 +0000 |
commit | f7a0594da71bf1e1d717145fe754d65baab27631 (patch) | |
tree | 2b83d21ab33064774969852fa01691cf3c206f9d /regress/usr.bin | |
parent | b724bad096c56ee5fd0d8822a1a543726a6fd10f (diff) |
add an extra test to ensure that authentication with the wrong
certificate fails as it should (and it does)
Diffstat (limited to 'regress/usr.bin')
-rw-r--r-- | regress/usr.bin/ssh/cert-hostkey.sh | 29 | ||||
-rw-r--r-- | regress/usr.bin/ssh/cert-userkey.sh | 18 |
2 files changed, 44 insertions, 3 deletions
diff --git a/regress/usr.bin/ssh/cert-hostkey.sh b/regress/usr.bin/ssh/cert-hostkey.sh index 14cd2230b63..2f87b9a43b9 100644 --- a/regress/usr.bin/ssh/cert-hostkey.sh +++ b/regress/usr.bin/ssh/cert-hostkey.sh @@ -1,4 +1,4 @@ -# $OpenBSD: cert-hostkey.sh,v 1.1 2010/02/26 20:33:21 djm Exp $ +# $OpenBSD: cert-hostkey.sh,v 1.2 2010/03/03 00:47:23 djm Exp $ # Placed in the Public Domain. tid="certified host keys" @@ -119,4 +119,31 @@ for ktype in rsa dsa ; do fi done +# Wrong certificate +( + echo -n '@cert-authority ' + echo -n "$HOSTS " + cat $OBJ/host_ca_key.pub +) > $OBJ/known_hosts-cert +for ktype in rsa dsa ; do + # Self-sign key + ${SSHKEYGEN} -h -q -s $OBJ/cert_host_key_${ktype} \ + -I "regress host key for $USER" \ + -n $HOSTS $OBJ/cert_host_key_${ktype} || + fail "couldn't sign cert_host_key_${ktype}" + verbose "$tid: host ${ktype} connect wrong cert" + ( + cat $OBJ/sshd_proxy_bak + echo HostKey $OBJ/cert_host_key_${ktype} + echo HostCertificate $OBJ/cert_host_key_${ktype}-cert.pub + ) > $OBJ/sshd_proxy + + ${SSH} -2 -oUserKnownHostsFile=$OBJ/known_hosts-cert \ + -oGlobalKnownHostsFile=$OBJ/known_hosts-cert \ + -F $OBJ/ssh_proxy -q somehost true >/dev/null 2>&1 + if [ $? -eq 0 ]; then + fail "ssh cert connect $ident succeeded unexpectedly" + fi +done + rm -f $OBJ/known_hosts-cert $OBJ/host_ca_key* $OBJ/cert_host_key* diff --git a/regress/usr.bin/ssh/cert-userkey.sh b/regress/usr.bin/ssh/cert-userkey.sh index 307e7236fb2..c1d2cdee701 100644 --- a/regress/usr.bin/ssh/cert-userkey.sh +++ b/regress/usr.bin/ssh/cert-userkey.sh @@ -1,4 +1,4 @@ -# $OpenBSD: cert-userkey.sh,v 1.1 2010/02/26 20:33:21 djm Exp $ +# $OpenBSD: cert-userkey.sh,v 1.2 2010/03/03 00:47:23 djm Exp $ # Placed in the Public Domain. tid="certified user keys" @@ -24,7 +24,6 @@ for ktype in rsa dsa ; do "regress user key for $USER" \ -n $USER $OBJ/cert_user_key_${ktype} || fail "couldn't sign cert_user_key_${ktype}" - done # Basic connect tests @@ -86,4 +85,19 @@ test_one "cert valid interval" success "-V-1w:+2w" test_one "wrong source-address" failure "-Osource-address=10.0.0.0/8" test_one "force-command" failure "-Oforce-command=false" +# Wrong certificate +for ktype in rsa dsa ; do + # Self-sign + ${SSHKEYGEN} -q -s $OBJ/cert_user_key_${ktype} -I \ + "regress user key for $USER" \ + -n $USER $OBJ/cert_user_key_${ktype} || + fail "couldn't sign cert_user_key_${ktype}" + verbose "$tid: user ${ktype} connect wrong cert" + ${SSH} -2i $OBJ/cert_user_key_${ktype} -F $OBJ/ssh_proxy \ + somehost true >/dev/null 2>&1 + if [ $? -eq 0 ]; then + fail "ssh cert connect $ident succeeded unexpectedly" + fi +done + rm -f $OBJ/authorized_keys_$USER $OBJ/user_ca_key* $OBJ/cert_user_key* |