From a8c844c9c2e0edf63543f5164d76ca7e6fbba286 Mon Sep 17 00:00:00 2001 From: Jakub Jelen Date: Thu, 21 Sep 2023 18:00:00 +0200 Subject: [PATCH] pki: Make sure imported certificate is certificate Signed-off-by: Jakub Jelen Reviewed-by: Sahana Prasad --- src/pki.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/pki.c b/src/pki.c index 96e128c2..92224664 100644 --- a/src/pki.c +++ b/src/pki.c @@ -1868,7 +1868,18 @@ int ssh_pki_import_cert_blob(const ssh_string cert_blob, */ int ssh_pki_import_cert_file(const char *filename, ssh_key *pkey) { - return ssh_pki_import_pubkey_file(filename, pkey); + int rc; + + rc = ssh_pki_import_pubkey_file(filename, pkey); + if (rc == SSH_OK) { + /* check the key is a cert type. */ + if (!is_cert_type((*pkey)->type)) { + SSH_KEY_FREE(*pkey); + return SSH_ERROR; + } + } + + return rc; } /**