Jump to content
xorpas

Enable protocol TLS 1.3 on Windows 7

Recommended Posts

Hello

I need to get html with tnethttpclient from site that use a latest versions of the Transport Layer Security (TLS 1.3)   this site icons8 I modify the registry but not work

How can do it on windows 7 ? or if their other way to get html;

 

Share this post


Link to post

The all-purpose solution is Curl. The curl.exe program is part of current Windows versions. Links: GitHub, Download, Manual, libcurl C API and libcurl C examples. An encapsulation for libcurl DLL can be found in the mORMot unit mormot.lib.curl. The mORMot library does not need to be installed. Download the current commit and the static binaries from the last tag directory. Set the appropriate library and search paths in Delphi. This pattern helps to create them:

// Simply replace the colons with the save path
..\src;..\src\app;..\src\core;..\src\crypt;..\src\db;..\src\lib;..\src\misc;..\src\net;..\src\orm;..\src\rest;..\src\script;..\src\soa;..\src\tools\ecc;..\src\ui;

For many use cases you can find a template in the libcurl C examples. The following Delphi example shows the implementation for a download:

uses
  mormot.core.base,
  mormot.core.text,
  mormot.core.os,
  mormot.lib.curl;

var
  hnd: TCurl;
  url: RawUtf8;
  res: TCurlResult;
  buffer: RawByteString;
  responseSize: Int64;
begin
  if not CurlIsAvailable then Exit; //=>

  hnd := curl.easy_init;
  if hnd <> Nil then
  begin
    url := 'https://icons8.com/icons/set/home.html';
    curl.easy_setopt(hnd, coURL, Pointer(url));
    curl.easy_setopt(hnd, coSSLVerifyPeer, 0);
    curl.easy_setopt(hnd, coSSLVerifyHost, 0);
    curl.easy_setopt(hnd, coWriteFunction, @CurlWriteRawByteString);
    curl.easy_setopt(hnd, coWriteData, @buffer);
    res := curl.easy_perform(hnd);
    if res = crOk then
    begin
      FileFromString(buffer, MakePath([Executable.ProgramFilePath, 'home.html']));
      
      curl.easy_getinfo(hnd, ciSizeDownloadT, responseSize);
      ShowMessage(Format('Download completed: %s', [KB(responseSize)]));
    end
    else
      ShowMessage(Format('Curl told us %d (%s)', [Ord(res), curl.easy_strerror(res)]));

    curl.easy_cleanup(hnd);
  end;
end;

An example to study is also the class TCurlHttp from the unit mormot.net.client.

 

With best regards

Thomas

Edited by mytbo
  • Thanks 1

Share this post


Link to post
On 2/5/2023 at 9:02 PM, mytbo said:

The all-purpose solution is Curl. The curl.exe program is part of current Windows versions. Links: GitHub, Download, Manual, libcurl C API and libcurl C examples. An encapsulation for libcurl DLL can be found in the mORMot unit mormot.lib.curl. The mORMot library does not need to be installed. Download the current commit and the static binaries from the last tag directory. Set the appropriate library and search paths in Delphi. This pattern helps to create them:


// Simply replace the colons with the save path
..\src;..\src\app;..\src\core;..\src\crypt;..\src\db;..\src\lib;..\src\misc;..\src\net;..\src\orm;..\src\rest;..\src\script;..\src\soa;..\src\tools\ecc;..\src\ui;

For many use cases you can find a template in the libcurl C examples. The following Delphi example shows the implementation for a download:


uses
  mormot.core.base,
  mormot.core.text,
  mormot.core.os,
  mormot.lib.curl;

var
  hnd: TCurl;
  url: RawUtf8;
  res: TCurlResult;
  buffer: RawByteString;
  responseSize: Int64;
begin
  if not CurlIsAvailable then Exit; //=>

  hnd := curl.easy_init;
  if hnd <> Nil then
  begin
    url := 'https://icons8.com/icons/set/home.html';
    curl.easy_setopt(hnd, coURL, Pointer(url));
    curl.easy_setopt(hnd, coSSLVerifyPeer, 0);
    curl.easy_setopt(hnd, coSSLVerifyHost, 0);
    curl.easy_setopt(hnd, coWriteFunction, @CurlWriteRawByteString);
    curl.easy_setopt(hnd, coWriteData, @buffer);
    res := curl.easy_perform(hnd);
    if res = crOk then
    begin
      FileFromString(buffer, MakePath([Executable.ProgramFilePath, 'home.html']));
      
      curl.easy_getinfo(hnd, ciSizeDownloadT, responseSize);
      ShowMessage(Format('Download completed: %s', [KB(responseSize)]));
    end
    else
      ShowMessage(Format('Curl told us %d (%s)', [Ord(res), curl.easy_strerror(res)]));

    curl.easy_cleanup(hnd);
  end;
end;

An example to study is also the class TCurlHttp from the unit mormot.net.client.

 

With best regards

Thomas

Thank's Mr thomas Not work for me see this image

 

Untitled.thumb.png.4e2d88d65172f5cb0e8099e442703667.png

can you upload the work project to test it

 

 

Share this post


Link to post
Guest

The version of libcurl.dll may be different, function exports may be missing in the dll, you can try with different dll versions.
Is the dll version compiled for x32 or x64, Is your application compiled for x32 or x64 on windows, review them too.

Share this post


Link to post
21 hours ago, mytbo said:

The all-purpose solution is Curl. The curl.exe program is part of current Windows versions.

By default, (lib)curl uses OpenSSL for SSL/TLS.  Guess what else uses OpenSSL by default?  Indy, which is pre-installed in Delphi.

  • Like 2

Share this post


Link to post

Your libcurl DLL version is out of date (12-Oct-16). Download the latest version for your OS from the official site.

 

With best regards

Thomas

  • Like 1

Share this post


Link to post
On 2/6/2023 at 7:05 PM, mytbo said:

Your libcurl DLL version is out of date (12-Oct-16). Download the latest version for your OS from the official site.

 

With best regards

Thomas

I download a latest version but the same problem

Untitled.thumb.png.db84113fc9b30e319fb60691aaf64653.png

Please upload a work project to test it

Share this post


Link to post
1 hour ago, xorpas said:

I download a latest version but the same problem

No, you are using the wrong libcurl DLL. Please download the file only from the official site and do not use any other source. Here is the link to the Windows download. The file for curl for 32-bit has the name curl-7.87.0_4-win32-mingw.zip and SHA256: ef8730e31245ef138aba1e3f02ae02e3fce435ec89177d7c8b05de5ce3c07891. The libcurl DLL has the modification date: Wednesday, December 21, 2022, 07:05:38. File size is 4,405,320 bytes.

 

With best regards

Thomas

  • Like 2

Share this post


Link to post
On 2/7/2023 at 6:40 PM, mytbo said:

No, you are using the wrong libcurl DLL. Please download the file only from the official site and do not use any other source. Here is the link to the Windows download. The file for curl for 32-bit has the name curl-7.87.0_4-win32-mingw.zip and SHA256: ef8730e31245ef138aba1e3f02ae02e3fce435ec89177d7c8b05de5ce3c07891. The libcurl DLL has the modification date: Wednesday, December 21, 2022, 07:05:38. File size is 4,405,320 byt

With best regards

Thomas

Thank you mr Thomas It work now thank's for your time :classic_love:

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×