Skip to content

Commit 0872c81

Browse files
add support for openSSL 3.x
This is needed to download the tracker list FPC 3.2.2 does not support OpenSSL 3.x
1 parent 3a152ef commit 0872c81

File tree

1 file changed

+45
-1
lines changed

1 file changed

+45
-1
lines changed

source/code/ngosang_trackerslist.pas

Lines changed: 45 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ TngosangTrackerList = class
6666

6767
implementation
6868

69-
uses fphttpclient, LazUTF8, torrent_miscellaneous;
69+
uses opensslsockets, OpenSSL, fphttpclient, LazUTF8, torrent_miscellaneous;
7070

7171
const
7272
URL: array [Tngosang_List] of string =
@@ -104,6 +104,7 @@ constructor TngosangTrackerList.Create;
104104
var
105105
i: Tngosang_List;
106106
begin
107+
107108
//Create all the TStringList
108109
for i in Tngosang_List do
109110
begin
@@ -125,4 +126,47 @@ destructor TngosangTrackerList.Destroy;
125126
inherited Destroy;
126127
end;
127128

129+
initialization
130+
// FPC 3.2.2 is missing support for the latest openSSL 3, will be fix in the future release.
131+
// Latest openssl.pas https://gitlab.com/freepascal.org/fpc/source/-/blob/main/packages/openssl/src/openssl.pas?ref_type=heads
132+
// Copy this newer SSL detection into the older openssl code used by the present FPC 3.2.2
133+
{$IFDEF VER3_2}
134+
{$IFDEF WINDOWS}
135+
DLLSSLName3 := {$IFDEF WIN64}'libssl-3-x64.dll'{$ELSE}'libssl-3.dll'{$ENDIF};
136+
DLLUtilName2 := {$IFDEF WIN64}'libcrypto-3-x64.dll'{$ELSE}'libcrypto-3.dll'{$ENDIF};
137+
{$ELSE WINDOWS}
138+
{$IFDEF DARWIN}
139+
if High(OpenSSL.DLLVersions) >= 19 then
140+
begin
141+
// macOS version
142+
// LibreSSL
143+
OpenSSL.DLLVersions[1] := '.48';
144+
OpenSSL.DLLVersions[2] := '.47';
145+
OpenSSL.DLLVersions[3] := '.46';
146+
OpenSSL.DLLVersions[4] := '.45';
147+
OpenSSL.DLLVersions[5] := '.44';
148+
OpenSSL.DLLVersions[6] := '.43';
149+
OpenSSL.DLLVersions[7] := '.35';
150+
151+
// OpenSSL
152+
OpenSSL.DLLVersions[8] := '.3';
153+
OpenSSL.DLLVersions[9] := '.1.1';
154+
OpenSSL.DLLVersions[10] := '.11';
155+
OpenSSL.DLLVersions[11] := '.10';
156+
OpenSSL.DLLVersions[12] := '.1.0.6';
157+
OpenSSL.DLLVersions[13] := '.1.0.5';
158+
OpenSSL.DLLVersions[14] := '.1.0.4';
159+
OpenSSL.DLLVersions[15] := '.1.0.3';
160+
OpenSSL.DLLVersions[16] := '.1.0.2';
161+
OpenSSL.DLLVersions[17] := '.1.0.1';
162+
OpenSSL.DLLVersions[18] := '.1.0.0';
163+
OpenSSL.DLLVersions[19] := '.0.9.8';
164+
end;
165+
{$ElSE DARWIN}
166+
// Unix/Linux version of FPC need openSSL 3 in the detection list
167+
OpenSSL.DLLVersions[Length(OpenSSL.DLLVersions) - 1] := '.3';
168+
{$ENDIF DARWIN}
169+
{$ENDIF WINDOWS}
170+
{$ENDIF VER3_2}
171+
128172
end.

0 commit comments

Comments
 (0)