Allow empty ISSigUrl for automatic handling.
This commit is contained in:
parent
369ea1627a
commit
12357a3acf
@ -72,17 +72,14 @@ begin
|
||||
DownloadPage.Clear;
|
||||
// Use AddEx or AddExWithISSigVerify to specify a username and password
|
||||
DownloadPage.AddWithISSigVerify(
|
||||
'https://jrsoftware.org/download.php/is.exe?dontcount=1',
|
||||
'https://jrsoftware.org/download.php/is.exe.issig',
|
||||
'https://jrsoftware.org/download.php/is.exe?dontcount=1', '',
|
||||
'innosetup-latest.exe', AllowedKeysRuntimeIDs);
|
||||
DownloadPage.AddWithISSigVerify(
|
||||
'https://jrsoftware.org/download.php/myprog-extrareadmes.7z',
|
||||
'https://jrsoftware.org/download.php/myprog-extrareadmes.7z.issig',
|
||||
'https://jrsoftware.org/download.php/myprog-extrareadmes.7z', '',
|
||||
'MyProg-ExtraReadmes.7z', AllowedKeysRuntimeIDs);
|
||||
DownloadPage.Add(
|
||||
'https://jrsoftware.org/download.php/iscrypt.dll?dontcount=1',
|
||||
'ISCrypt.dll',
|
||||
'2f6294f9aa09f59a574b5dcd33be54e16b39377984f3d5658cda44950fa0f8fc');
|
||||
'ISCrypt.dll', '2f6294f9aa09f59a574b5dcd33be54e16b39377984f3d5658cda44950fa0f8fc');
|
||||
DownloadPage.Show;
|
||||
try
|
||||
try
|
||||
|
@ -1862,6 +1862,7 @@ end;</pre>
|
||||
<name>DownloadTemporaryFileWithISSigVerify</name>
|
||||
<prototype>function DownloadTemporaryFileWithISSigVerify(const Url, ISSigUrl, BaseName: String; const AllowedKeysRuntimeIDs: TStringList; const OnDownloadProgress: TOnDownloadProgress): Int64;</prototype>
|
||||
<description><p>Like <link topic="isxfunc_DownloadTemporaryFile">DownloadTemporaryFile</link>, but downloads an .issig signature file first from the specified second URL and uses it to verify the main file downloaded from the first URL.</p>
|
||||
<p>If the second URL is an empty string, Setup will instead append ".issig" (without quotes) to the path portion of the first URL and use the result as the URL to download the .issig signature file from.</p>
|
||||
<p>Verification uses the specified allowed keys, looked up using <link topic="issigkeyssection">[ISSigKeys] section</link> parameter <tt>RuntimeID</tt>. To allow all keys set AllowedKeysRuntimeIDs to <tt>nil</tt>.</p>
|
||||
<p>An exception will be raised if there was an error. Otherwise, returns the number of bytes downloaded for the main file from the first URL. Returns 0 if the main file was already downloaded and still verified.</p></description>
|
||||
<seealso><p><link topic="isxfunc_DownloadTemporaryFile">DownloadTemporaryFile</link><br/>
|
||||
@ -1873,8 +1874,7 @@ function InitializeSetup: Boolean;
|
||||
begin
|
||||
try
|
||||
DownloadTemporaryFileWithISSigVerify(
|
||||
'https://jrsoftware.org/download.php/myprog-extrareadmes.7z',
|
||||
'https://jrsoftware.org/download.php/myprog-extrareadmes.7z.issig',
|
||||
'https://jrsoftware.org/download.php/myprog-extrareadmes.7z', '',
|
||||
'myprog-extrareadmes.7z', nil, nil);
|
||||
Result := True;
|
||||
except
|
||||
|
@ -35,6 +35,7 @@ function DownloadTemporaryFile(const Url, BaseName, RequiredSHA256OfFile: String
|
||||
function DownloadTemporaryFileSize(const Url: String): Int64;
|
||||
function DownloadTemporaryFileDate(const Url: String): String;
|
||||
procedure SetDownloadCredentials(const User, Pass: String);
|
||||
function GetISSigUrl(const Url, ISSigUrl: String): String;
|
||||
|
||||
implementation
|
||||
|
||||
@ -3669,10 +3670,8 @@ begin
|
||||
end;
|
||||
|
||||
function GetCredentialsAndCleanUrl(const Url: String; var User, Pass, CleanUrl: String) : Boolean;
|
||||
var
|
||||
Uri: TUri;
|
||||
begin
|
||||
Uri := TUri.Create(Url);
|
||||
const Uri = TUri.Create(Url); { This is a record so no need to free }
|
||||
if DownloadUser = '' then
|
||||
User := TNetEncoding.URL.Decode(Uri.Username)
|
||||
else
|
||||
@ -3691,6 +3690,17 @@ begin
|
||||
Log('Download is not using basic authentication');
|
||||
end;
|
||||
|
||||
function GetISSigUrl(const Url, ISSigUrl: String): String;
|
||||
begin
|
||||
if ISSigUrl <> '' then
|
||||
Result := ISSigUrl
|
||||
else begin
|
||||
const Uri = TUri.Create(Url); { This is a record so no need to free }
|
||||
Uri.Path := TNetEncoding.URL.Decode(Uri.Path) + ISSigExt;
|
||||
Result := Uri.ToString;
|
||||
end;
|
||||
end;
|
||||
|
||||
function DownloadTemporaryFile(const Url, BaseName, RequiredSHA256OfFile: String;
|
||||
const ISSigVerify: Boolean; const ISSigAllowedKeys: AnsiString;
|
||||
const OnDownloadProgress: TOnDownloadProgress): Int64;
|
||||
|
@ -1115,7 +1115,7 @@ function TDownloadWizardPage.AddExWithISSigVerify(const Url, ISSigUrl, BaseName,
|
||||
begin
|
||||
{ Also see Setup.ScriptFunc DownloadTemporaryFileWithISSigVerify }
|
||||
const ISSigAllowedKeys = ConvertAllowedKeysRuntimeIDsToISSigAllowedKeys(AllowedKeysRuntimeIDs);
|
||||
DoAdd(ISSigUrl, BaseName + ISSigExt, '', UserName, Password, False, '');
|
||||
DoAdd(GetISSigUrl(Url, ISSigUrl), BaseName + ISSigExt, '', UserName, Password, False, '');
|
||||
Result := DoAdd(Url, BaseName, '', UserName, Password, True, ISSigAllowedKeys);
|
||||
end;
|
||||
|
||||
|
@ -824,7 +824,7 @@ var
|
||||
|
||||
{ Also see Setup.ScriptDlg TDownloadWizardPage.AddExWithISSigVerify }
|
||||
if ISSigVerify then
|
||||
DownloadTemporaryFile(ISSigUrl, BaseName + ISSigExt, '', False, '', OnDownloadProgress);
|
||||
DownloadTemporaryFile(GetISSigUrl(Url, ISSigUrl), BaseName + ISSigExt, '', False, '', OnDownloadProgress);
|
||||
Stack.SetInt64(PStart, DownloadTemporaryFile(Url, BaseName, RequiredSHA256OfFile, ISSigVerify, ISSigAllowedKeys, OnDownloadProgress));
|
||||
end);
|
||||
RegisterScriptFunc('DownloadTemporaryFileSize', sfNoUninstall, procedure(const Caller: TPSExec; const OrgName: AnsiString; const Stack: TPSStack; const PStart: Cardinal)
|
||||
|
Loading…
x
Reference in New Issue
Block a user