From f11520377893841e4da73da842fb7bb0cf86b7ed Mon Sep 17 00:00:00 2001 From: phl0 Date: Mon, 13 May 2024 08:43:31 +0200 Subject: [PATCH 1/3] OpenSSL signatures need a newline after base64 string --- application/controllers/Lotw.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/application/controllers/Lotw.php b/application/controllers/Lotw.php index 2bae0a643..a74e0f8c0 100644 --- a/application/controllers/Lotw.php +++ b/application/controllers/Lotw.php @@ -976,7 +976,7 @@ class Lotw extends CI_Controller { openssl_free_key($pkeyid); } $signature_b64 = base64_encode($signature); - return $signature_b64; + return $signature_b64."\n"; } } else { log_message('error', 'Error signing LoTW log.'); From 02f9f6bb5c97ca43bc018dca2757c3b1b41f5c8e Mon Sep 17 00:00:00 2001 From: phl0 Date: Mon, 13 May 2024 09:17:43 +0200 Subject: [PATCH 2/3] Strip full path from upload filename --- application/controllers/Lotw.php | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/application/controllers/Lotw.php b/application/controllers/Lotw.php index a74e0f8c0..4bed10aee 100644 --- a/application/controllers/Lotw.php +++ b/application/controllers/Lotw.php @@ -307,20 +307,22 @@ class Lotw extends CI_Controller { //If the function curl_file_create exists if(function_exists('curl_file_create')){ //Use the recommended way, creating a CURLFile object. - $filePath = curl_file_create($filePath); + $uploadfile = curl_file_create($filePath); + $uploadfile->setPostFilename(basename($filePath)); } else{ //Otherwise, do it the old way. //Get the canonicalized pathname of our file and prepend //the @ character. - $filePath = '@' . realpath($filePath); + $uploadfile = '@' . realpath($filePath).';filename='.basename($filePath); //Turn off SAFE UPLOAD so that it accepts files //starting with an @ curl_setopt($ch, CURLOPT_SAFE_UPLOAD, false); } + //Setup our POST fields $postFields = array( - $uploadFieldName => $filePath + $uploadFieldName => $uploadfile ); curl_setopt($ch, CURLOPT_POSTFIELDS, $postFields); From e345975e9c1d8ffbde19bc4bae75480186b2cb76 Mon Sep 17 00:00:00 2001 From: phl0 Date: Mon, 13 May 2024 09:20:06 +0200 Subject: [PATCH 3/3] Remove deprecated way of creating upload files --- application/controllers/Lotw.php | 18 +++--------------- 1 file changed, 3 insertions(+), 15 deletions(-) diff --git a/application/controllers/Lotw.php b/application/controllers/Lotw.php index 4bed10aee..f8ecab952 100644 --- a/application/controllers/Lotw.php +++ b/application/controllers/Lotw.php @@ -304,21 +304,9 @@ class Lotw extends CI_Controller { //Tell cURL to return the output as a string. curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); - //If the function curl_file_create exists - if(function_exists('curl_file_create')){ - //Use the recommended way, creating a CURLFile object. - $uploadfile = curl_file_create($filePath); - $uploadfile->setPostFilename(basename($filePath)); - } else{ - //Otherwise, do it the old way. - //Get the canonicalized pathname of our file and prepend - //the @ character. - $uploadfile = '@' . realpath($filePath).';filename='.basename($filePath); - //Turn off SAFE UPLOAD so that it accepts files - //starting with an @ - curl_setopt($ch, CURLOPT_SAFE_UPLOAD, false); - } - + //Use the recommended way, creating a CURLFile object. + $uploadfile = curl_file_create($filePath); + $uploadfile->setPostFilename(basename($filePath)); //Setup our POST fields $postFields = array(