File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -757,14 +757,26 @@ public function verifyIntegrity(): void {
757757-----END CERTIFICATE-----
758758EOF ;
759759
760- $ validSignature = openssl_verify (
761- file_get_contents ($ this ->getDownloadedFilePath ()),
762- base64_decode ($ response ['signature ' ]),
763- $ certificate ,
764- OPENSSL_ALGO_SHA512
765- ) === 1 ;
766-
767- if ($ validSignature === false ) {
760+ $ fh = fopen ($ this ->getDownloadedFilePath (), 'r ' );
761+ if ($ fh === false ) {
762+ throw new \Exception ('Failed to open downloaded file for integrity check ' );
763+ }
764+
765+ $ data = '' ;
766+ while (!feof ($ fh )) {
767+ $ chunk = fread ($ fh , 8192 );
768+ if ($ chunk === false ) {
769+ fclose ($ fh );
770+ throw new \Exception ('Error reading file during integrity check ' );
771+ }
772+ $ data .= $ chunk ;
773+ }
774+ fclose ($ fh );
775+
776+ $ signature = base64_decode ($ response ['signature ' ]);
777+
778+ $ validSignature = openssl_verify ($ data , $ signature , $ certificate , OPENSSL_ALGO_SHA512 );
779+ if ($ validSignature !== 1 ) {
768780 throw new \Exception ('Signature of update is not valid ' );
769781 }
770782
Original file line number Diff line number Diff line change @@ -739,14 +739,26 @@ public function verifyIntegrity(): void {
739739-----END CERTIFICATE-----
740740EOF ;
741741
742- $ validSignature = openssl_verify (
743- file_get_contents ($ this ->getDownloadedFilePath ()),
744- base64_decode ($ response ['signature ' ]),
745- $ certificate ,
746- OPENSSL_ALGO_SHA512
747- ) === 1 ;
748-
749- if ($ validSignature === false ) {
742+ $ fh = fopen ($ this ->getDownloadedFilePath (), 'r ' );
743+ if ($ fh === false ) {
744+ throw new \Exception ('Failed to open downloaded file for integrity check ' );
745+ }
746+
747+ $ data = '' ;
748+ while (!feof ($ fh )) {
749+ $ chunk = fread ($ fh , 8192 );
750+ if ($ chunk === false ) {
751+ fclose ($ fh );
752+ throw new \Exception ('Error reading file during integrity check ' );
753+ }
754+ $ data .= $ chunk ;
755+ }
756+ fclose ($ fh );
757+
758+ $ signature = base64_decode ($ response ['signature ' ]);
759+
760+ $ validSignature = openssl_verify ($ data , $ signature , $ certificate , OPENSSL_ALGO_SHA512 );
761+ if ($ validSignature !== 1 ) {
750762 throw new \Exception ('Signature of update is not valid ' );
751763 }
752764
You can’t perform that action at this time.
0 commit comments