@@ -547,12 +547,12 @@ private function getUpdateServerResponse(): array {
547547 *
548548 * @throws \Exception
549549 */
550- public function downloadUpdate (string $ url = '' ): void {
550+ public function downloadUpdate (string $ urlOverride = '' ): void {
551551 $ this ->silentLog ('[info] downloadUpdate() ' );
552552
553- if ($ url !== '' ) {
553+ if ($ urlOverride !== '' ) {
554554 // If a URL is provided, use it directly
555- $ downloadURLs = [$ url ];
555+ $ downloadURLs = [$ urlOverride ];
556556 } else {
557557 // Otherwise, get the download URLs from the update server
558558 $ downloadURLs = $ this ->getDownloadURLs ();
@@ -577,10 +577,10 @@ public function downloadUpdate(string $url = ''): void {
577577 }
578578 }
579579
580- foreach ($ downloadURLs as $ url ) {
580+ foreach ($ downloadURLs as $ urlOverride ) {
581581 $ this ->previousProgress = 0 ;
582- $ saveLocation = $ storageLocation . basename ($ url );
583- if ($ this ->downloadArchive ($ url , $ saveLocation )) {
582+ $ saveLocation = $ storageLocation . basename ($ urlOverride );
583+ if ($ this ->downloadArchive ($ urlOverride , $ saveLocation )) {
584584 return ;
585585 }
586586 }
@@ -758,25 +758,21 @@ private function getDownloadedFilePath(): string {
758758 *
759759 * @throws \Exception
760760 */
761- public function verifyIntegrity (string $ urlOverride = '' ): void {
761+ public function verifyIntegrity (string $ urlOverride = '' , string $ signature = '' ): void {
762762 $ this ->silentLog ('[info] verifyIntegrity() ' );
763763
764764 if ($ this ->getCurrentReleaseChannel () === 'daily ' ) {
765765 $ this ->silentLog ('[info] current channel is "daily" which is not signed. Skipping verification. ' );
766766 return ;
767767 }
768768
769- if ($ urlOverride !== '' ) {
770- $ this ->silentLog ('[info] custom download url provided, cannot verify signature ' );
771- return ;
772- }
773-
774- $ response = $ this ->getUpdateServerResponse ();
775- if (empty ($ response ['signature ' ])) {
776- throw new \Exception ('No signature specified for defined update ' );
777- }
778- if (!is_string ($ response ['signature ' ])) {
779- throw new \Exception ('Signature specified for defined update should be a string ' );
769+ if ($ signature === '' ) {
770+ if ($ urlOverride !== '' ) {
771+ throw new \Exception (
772+ 'Custom download url provided. You need to provide a signature with --signature or skip integrity check with --no-verify. '
773+ );
774+ }
775+ $ signature = $ this ->getSignatureFromUpdater ();
780776 }
781777
782778 $ certificate = <<<EOF
@@ -811,7 +807,7 @@ public function verifyIntegrity(string $urlOverride = ''): void {
811807
812808 $ validSignature = openssl_verify (
813809 file_get_contents ($ this ->getDownloadedFilePath ()),
814- base64_decode ($ response [ ' signature ' ] ),
810+ base64_decode ($ signature ),
815811 $ certificate ,
816812 OPENSSL_ALGO_SHA512
817813 ) === 1 ;
@@ -823,6 +819,19 @@ public function verifyIntegrity(string $urlOverride = ''): void {
823819 $ this ->silentLog ('[info] end of verifyIntegrity() ' );
824820 }
825821
822+ private function getSignatureFromUpdater (): string {
823+ $ response = $ this ->getUpdateServerResponse ();
824+ if (empty ($ response ['signature ' ])) {
825+ throw new \Exception ('No signature specified for defined update ' );
826+ }
827+
828+ if (!is_string ($ response ['signature ' ])) {
829+ throw new \Exception ('Signature specified for defined update should be a string ' );
830+ }
831+
832+ return $ response ['signature ' ];
833+ }
834+
826835 /**
827836 * Gets the version as declared in $versionFile
828837 *
0 commit comments