Skip to content

Commit ff409a9

Browse files
committed
Check if key has a passphrase
1 parent af1b5b1 commit ff409a9

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

imageroot/actions/upload-certificate/21validate_certificates

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,27 @@ set -e
99

1010
CERT_FILE=uploaded_cert
1111
KEY_FILE=uploaded_key
12+
PASSPHRASE_KEY=0
1213
VALID_KEY=0
1314
TYPE_KEY=""
1415

1516
del_certs() {
1617
rm -f $KEY_FILE $CERT_FILE
1718
}
1819

20+
# checking if key has a passphrase
21+
if openssl rsa -check -in $KEY_FILE -passin pass:1234 >/dev/null 2>&1; then
22+
PASSPHRASE_KEY=1
23+
fi
24+
25+
if [ $PASSPHRASE_KEY -eq 0 ]; then
26+
echo "A key with a passphrase is not allowed." 1>&2
27+
echo "set-status validation-failed" >&${AGENT_COMFD:-2}
28+
printf '[{"field":"keyFile","parameter":"keyFile","value":"","error":"invalid_key"}]\n'
29+
del_certs
30+
exit 2
31+
fi
32+
1933
# checking if key is valid
2034
if openssl rsa -check -in $KEY_FILE >/dev/null 2>&1; then
2135
VALID_KEY=1

0 commit comments

Comments
 (0)