From 36cb64b3e26bfe994cc9d0b26e63634c770f945f Mon Sep 17 00:00:00 2001 From: HB9HIL Date: Mon, 19 Aug 2024 16:37:27 +0200 Subject: [PATCH] catch the case if a p12 file does only contain a key --- application/controllers/Lotw.php | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/application/controllers/Lotw.php b/application/controllers/Lotw.php index 658acba4d..895bce184 100644 --- a/application/controllers/Lotw.php +++ b/application/controllers/Lotw.php @@ -405,7 +405,14 @@ class Lotw extends CI_Controller { $filename = file_get_contents('file://'.$file); $worked = openssl_pkcs12_read($filename, $results, $password); - $data['general_cert'] = $results['cert']; + if ($results['cert']) { + $data['general_cert'] = $results['cert']; + } else { + log_message('error', 'Found no cert in '.$file); + unlink($file); + $this->session->set_flashdata('warning', sprintf(__("Found no cert in %s. If the filename contains 'key-only', this p12 file is not activated by LoTW yet."), $file)); + redirect('lotw'); + } if($worked) {