Recent

Author Topic: TPQConnection and auth for scram-sha-256 or md5  (Read 1921 times)

noszone

  • New Member
  • *
  • Posts: 21
TPQConnection and auth for scram-sha-256 or md5
« on: June 18, 2021, 05:08:57 am »
I have installed Postgresql 13 and connection from this DB only possible with auth method trust. So TPQConnection does not requires any password (through some old libpq.dll, which says "auth method 10 is not supporting" if I change it in ph_hba.conf), but I need for our Lazarus app the auth by password.

I've tried to use a bunch of files from PG 13, PG10 installations - both x32 & x64 dlls, but no luck. Does anyone know if TPQConnection (or other component maybe?) supporting PG 13 with auth scram-sha-256 or md5 by password?

The files I tried to use:
From PG10 x32 and from PG13 installed on my pc from bin folder:

libcrypto-1_1-x64.dll
libiconv-2.dll
libintl-8.dll
libpq.dll
libssl-1_1-x64.dll

Please help..

Additionally adding some shots (1st is debug mode, 2nd is exe run).
« Last Edit: June 18, 2021, 05:22:17 am by noszone »

noszone

  • New Member
  • *
  • Posts: 21
Re: TPQConnection and auth for scram-sha-256 or md5
« Reply #1 on: June 18, 2021, 06:28:42 am »
Solved, helped to me to put a PATH system variables:

C:\Program Files\PostgreSQL\13\bin
C:\Program Files\PostgreSQL\13\lib

This in case if your Lazarus App is x64. If you want run x32 Laz App, so you have to provide to PATH a x32 binaries (dlls):

D:\PG\13\bin
D:\PG\13\lib

Binaries can be downloaded (the last x32 binaries is PG 10v) - https://www.enterprisedb.com/download-postgresql-binaries

Alternative way (not requires PATH variables):

Open your project *.lpr file in any text editor, you will see:

Code: Pascal  [Select][+][-]
  1. program project1;
  2.  
  3. {$mode objfpc}{$H+}
  4.  
  5. uses
  6.   {$IFDEF UNIX}{$IFDEF UseCThreads}
  7.   cthreads,
  8.   {$ENDIF}{$ENDIF}
  9.   Interfaces, // this includes the LCL widgetset
  10.   Forms, Unit1
  11.   { you can add units after this };
  12.  
  13. {$R *.res}
  14.  
  15. begin
  16.   RequireDerivedFormResource:=True;
  17.   Application.Scaled:=True;
  18.   Application.Initialize;
  19.   Application.CreateForm(TForm1, Form1);
  20.   Application.Run;
  21. end.
  22.  

Modify it to:

Code: Pascal  [Select][+][-]
  1. program project1;
  2.  
  3. {$mode objfpc}{$H+}
  4.  
  5. uses
  6.   {$IFDEF UNIX}{$IFDEF UseCThreads}
  7.   cthreads,
  8.   {$ENDIF}{$ENDIF}
  9.   Interfaces, // this includes the LCL widgetset
  10.   Forms, Unit1
  11.   { you can add units after this };
  12.  
  13. function SetDllDirectory(lpPathName:PWideChar): Boolean; stdcall; external 'kernel32.dll' name 'SetDllDirectoryW';
  14.  
  15. {$R *.res}
  16.  
  17. begin
  18.   SetDllDirectory(PWideChar('D:\Sources\tst'));
  19.   RequireDerivedFormResource:=True;
  20.   Application.Scaled:=True;
  21.   Application.Initialize;
  22.   Application.CreateForm(TForm1, Form1);
  23.   Application.Run;
  24. end.

So in the folder path you can put your dlls from Postgres. Note that it's will work only in run-time mode. For debug mode you still need a PATH variables.
« Last Edit: June 18, 2021, 07:10:06 am by noszone »

 

TinyPortal © 2005-2018