Skip to content

Commit ecdf9b9

Browse files
committed
upstream: regression tests for certificates with empty principals
sections (which are now unconditionally refused) and for certificates with wildcard principals (which should only be accepted in host certs) OpenBSD-Regress-ID: fdca88845a68424060547b4f9f32f90a7cf82e73
1 parent adca2f4 commit ecdf9b9

File tree

2 files changed

+21
-16
lines changed

2 files changed

+21
-16
lines changed

regress/cert-hostkey.sh

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# $OpenBSD: cert-hostkey.sh,v 1.28 2025/05/06 06:05:48 djm Exp $
1+
# $OpenBSD: cert-hostkey.sh,v 1.29 2025/12/22 01:50:46 djm Exp $
22
# Placed in the Public Domain.
33

44
tid="certified host keys"
@@ -208,9 +208,12 @@ kh_ca host_ca_key.pub host_ca_key2.pub > $OBJ/known_hosts-cert.orig
208208
cp $OBJ/known_hosts-cert.orig $OBJ/known_hosts-cert
209209

210210
test_one() {
211-
ident=$1
212-
result=$2
213-
sign_opts=$3
211+
ident="$1"
212+
result="$2"
213+
hosts="$3"
214+
sign_opts="$4"
215+
216+
test -z "$hosts" || sign_opts="$sign_opts -n $hosts"
214217

215218
for kt in $PLAIN_TYPES; do
216219
case $ktype in
@@ -243,13 +246,16 @@ test_one() {
243246
done
244247
}
245248

246-
test_one "user-certificate" failure "-n $HOSTS"
247-
test_one "empty principals" success "-h"
248-
test_one "wrong principals" failure "-h -n foo"
249-
test_one "cert not yet valid" failure "-h -V20300101:20320101"
250-
test_one "cert expired" failure "-h -V19800101:19900101"
251-
test_one "cert valid interval" success "-h -V-1w:+2w"
252-
test_one "cert has constraints" failure "-h -Oforce-command=false"
249+
test_one "simple" success $HOSTS "-h"
250+
test_one "wildcard" success "loc*" "-h"
251+
test_one "user-certificate" failure $HOSTS
252+
test_one "wildcard user" failure "local*"
253+
test_one "empty principals" failure "" "-h"
254+
test_one "wrong principals" failure foo "-h"
255+
test_one "cert not yet valid" failure $HOSTS "-h -V20300101:20320101"
256+
test_one "cert expired" failure $HOSTS "-h -V19800101:19900101"
257+
test_one "cert valid interval" success $HOSTS "-h -V-1w:+2w"
258+
test_one "cert has constraints" failure $HOSTS "-h -Oforce-command=false"
253259

254260
# Check downgrade of cert to raw key when no CA found
255261
for ktype in $PLAIN_TYPES ; do

regress/cert-userkey.sh

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# $OpenBSD: cert-userkey.sh,v 1.30 2025/05/06 06:05:48 djm Exp $
1+
# $OpenBSD: cert-userkey.sh,v 1.31 2025/12/22 01:50:46 djm Exp $
22
# Placed in the Public Domain.
33

44
tid="certified user keys"
@@ -340,16 +340,15 @@ test_one() {
340340
}
341341

342342
test_one "correct principal" success "-n ${USER}"
343+
test_one "correct principal" success "-n ${USER},*"
343344
test_one "host-certificate" failure "-n ${USER} -h"
344-
test_one "wrong principals" failure "-n foo"
345+
test_one "wrong principals" failure "-n foo,*"
345346
test_one "cert not yet valid" failure "-n ${USER} -V20300101:20320101"
346347
test_one "cert expired" failure "-n ${USER} -V19800101:19900101"
347348
test_one "cert valid interval" success "-n ${USER} -V-1w:+2w"
348349
test_one "wrong source-address" failure "-n ${USER} -Osource-address=10.0.0.0/8"
349350
test_one "force-command" failure "-n ${USER} -Oforce-command=false"
350-
351-
# Behaviour is different here: TrustedUserCAKeys doesn't allow empty principals
352-
test_one "empty principals" success "" authorized_keys
351+
test_one "empty principals" failure "" authorized_keys
353352
test_one "empty principals" failure "" TrustedUserCAKeys
354353

355354
# Check explicitly-specified principals: an empty principals list in the cert

0 commit comments

Comments
 (0)