@@ -112,7 +112,7 @@ jobs:
112112 run : |
113113 cd wolfssh
114114 ./autogen.sh
115- ./configure --enable-tpm --enable-certs
115+ ./configure --enable-tpm --enable-certs --enable-ossh-certs
116116 make
117117 sudo make install
118118 sudo ldconfig
@@ -230,6 +230,60 @@ jobs:
230230 timeout 20 ./examples/client/client -i ../wolftpm/keyblob.bin \
231231 -u hansel -K ThisIsMyKeyAuth
232232
233+ # The same TPM key offered as an OpenSSH user certificate. The certificate
234+ # is a file carrying the TPM key's public half; the TPM still signs.
235+ - name : Test TPM client OpenSSH certificate auth
236+ if : matrix.keytype == 'rsa' && matrix.hostkey == 'raw'
237+ run : |
238+ cd wolfssh
239+ ssh-keygen -q -t rsa -N '' -f ossh_ca < /dev/null
240+ cp key.ssh tpmkey.pub
241+ ssh-keygen -q -s ossh_ca -I tpm-cert -n hansel tpmkey.pub
242+ timeout 30 ./examples/echoserver/echoserver -1 -p 22225 -s key.ssh \
243+ > ossh_cert_server.txt 2>&1 &
244+ SERVER_PID=$!
245+ echo "Echoserver (TPM key behind an OpenSSH certificate) PID: $SERVER_PID"
246+ sleep 2
247+ timeout 20 ./examples/client/client -i ../wolftpm/keyblob.bin \
248+ -u hansel -K ThisIsMyKeyAuth -j tpmkey-cert.pub -p 22225 -x \
249+ < /dev/null > ossh_cert_client.txt 2>&1 || {
250+ cat ossh_cert_client.txt
251+ exit 1
252+ }
253+ # The one-shot server flushes its output when it exits.
254+ wait $SERVER_PID || true
255+ echo "----- server -----"; cat ossh_cert_server.txt
256+ grep -q "auth = Success" ossh_cert_server.txt
257+
258+ # Negative test: a certificate for another key. The echoserver accepts
259+ # that key, so only the signature check can refuse the TPM's signature.
260+ - name : Test TPM client OpenSSH certificate for another key fails
261+ if : matrix.keytype == 'rsa' && matrix.hostkey == 'raw'
262+ run : |
263+ cd wolfssh
264+ # Same size as the TPM key, or the client fails before signing. The
265+ # comment is cut because the echoserver appends the user name.
266+ ssh-keygen -q -t rsa -b 2048 -N '' -f other < /dev/null
267+ ssh-keygen -q -s ossh_ca -I other-cert -n hansel other.pub
268+ cut -d' ' -f1,2 other.pub > other.ssh
269+ timeout 30 ./examples/echoserver/echoserver -1 -p 22226 -s other.ssh \
270+ > ossh_cert_server_neg.txt 2>&1 &
271+ SERVER_PID=$!
272+ echo "Echoserver (another key's certificate) PID: $SERVER_PID"
273+ sleep 2
274+ if timeout 20 ./examples/client/client -i ../wolftpm/keyblob.bin \
275+ -u hansel -K ThisIsMyKeyAuth -j other-cert.pub -p 22226 -x \
276+ < /dev/null > ossh_cert_client_neg.txt 2>&1; then
277+ echo "ERROR: a certificate for another key authenticated"
278+ cat ossh_cert_client_neg.txt
279+ exit 1
280+ fi
281+ wait $SERVER_PID || true
282+ echo "----- server -----"; cat ossh_cert_server_neg.txt
283+ echo "----- client -----"; cat ossh_cert_client_neg.txt
284+ # The server took the key and then refused the signature.
285+ grep -q "auth = Failure" ossh_cert_server_neg.txt
286+
233287 - name : Archive test artifacts
234288 if : always()
235289 uses : actions/upload-artifact@v7
@@ -243,4 +297,8 @@ jobs:
243297 wolfssh/tpmcert_client.txt
244298 wolfssh/tpmcert_server_neg.txt
245299 wolfssh/tpmcert_client_neg.txt
300+ wolfssh/ossh_cert_server.txt
301+ wolfssh/ossh_cert_client.txt
302+ wolfssh/ossh_cert_server_neg.txt
303+ wolfssh/ossh_cert_client_neg.txt
246304 wolfssh/tests/api.log
0 commit comments