public inbox for [email protected]  
help / color / mirror / Atom feed
PQconnectdbParams and encrypted password
3+ messages / 2 participants
[nested] [flat]

* PQconnectdbParams and encrypted password
@ 2019-08-30 04:19  Dmitry Markman <[email protected]>
  0 siblings, 1 reply; 3+ messages in thread

From: Dmitry Markman @ 2019-08-30 04:19 UTC (permalink / raw)
  To: [email protected]

Hi
I need some help with setting PQconnectdbParams key/value for encrypted password

suppose I created user with the string

create user foobar with encrypted password ‘md5f3c33545d22dbf811737afb8d0e85597’

I was able to connect successfully using 

psql -U foobar

I guess my pg_hba.conf is OK:

local   all             foobar                                    md5
host    all             foobar              127.0.0.1/32          md5
host    all             foobar              0.0.0.0/0             md5

however

I have a problem to connect to the server from my C++ program using PQconnectdbParams function

            const std::pair<std::string, std::string> connParams[] = {
                {"host", “localhost"},
                {"port", ""},
                {"user", “foobar"},
                {"password", ??????????????},//I’d like to have here “md5f3c33545d22dbf811737afb8d0e85597”, but it doesn’t work
                {"options","password_encryption='md5'"},
                {"dbname", "test_db"},
                {"connect_timeout", “10"} 
            };
            const char* keywords[] = {connParams[0].first.c_str(),
                                      connParams[1].first.c_str(),
                                      connParams[2].first.c_str(),
                                      connParams[3].first.c_str(),
                                      connParams[4].first.c_str(),
                                      connParams[5].first.c_str(),
                                      connParams[6].first.c_str(),
                                      nullptr};
            const char* connValues[] = {connParams[0].second.c_str(),
                                        connParams[1].second.c_str(),
                                        connParams[2].second.c_str(),
                                        connParams[3].second.c_str(),
                                        connParams[4].second.c_str(),
                                        connParams[5].second.c_str(),
                                        connParams[6].second.c_str(),
                                        nullptr};

		auto db = PQconnectdbParams(keywords, connValues)


whatever I tried ConnStatusType of the db is CONNECTION_BAD

if I use value as “open” string for the key=“password”, then connection was successful


thanks in advance

dm











^ permalink  raw  reply  [nested|flat] 3+ messages in thread

* Re: PQconnectdbParams and encrypted password
@ 2019-08-30 13:50  Tom Lane <[email protected]>
  parent: Dmitry Markman <[email protected]>
  0 siblings, 1 reply; 3+ messages in thread

From: Tom Lane @ 2019-08-30 13:50 UTC (permalink / raw)
  To: Dmitry Markman <[email protected]>; +Cc: [email protected]

Dmitry Markman <[email protected]> writes:
> I need some help with setting PQconnectdbParams key/value for encrypted password
> suppose I created user with the string
> create user foobar with encrypted password ‘md5f3c33545d22dbf811737afb8d0e85597’
> ...
>                 {"password", ??????????????},//I’d like to have here “md5f3c33545d22dbf811737afb8d0e85597”, but it doesn’t work

Pretty much the entire *point* of an encrypted password is that the
md5 hash is not sufficient to log in with.  You need the original
string.

			regards, tom lane





^ permalink  raw  reply  [nested|flat] 3+ messages in thread

* Re: PQconnectdbParams and encrypted password
@ 2019-08-30 22:48  Dmitry Markman <[email protected]>
  parent: Tom Lane <[email protected]>
  0 siblings, 0 replies; 3+ messages in thread

From: Dmitry Markman @ 2019-08-30 22:48 UTC (permalink / raw)
  To: Tom Lane <[email protected]>; +Cc: [email protected]

Hi Tom

thanks a lot for your answer

I realized it almost immediately after I press the button send :)

thanks again

 dm


> On Aug 30, 2019, at 9:50 AM, Tom Lane <[email protected]> wrote:
> 
> Dmitry Markman <[email protected]> writes:
>> I need some help with setting PQconnectdbParams key/value for encrypted password
>> suppose I created user with the string
>> create user foobar with encrypted password ‘md5f3c33545d22dbf811737afb8d0e85597’
>> ...
>>                {"password", ??????????????},//I’d like to have here “md5f3c33545d22dbf811737afb8d0e85597”, but it doesn’t work
> 
> Pretty much the entire *point* of an encrypted password is that the
> md5 hash is not sufficient to log in with.  You need the original
> string.
> 
> 			regards, tom lane






^ permalink  raw  reply  [nested|flat] 3+ messages in thread


end of thread, other threads:[~2019-08-30 22:48 UTC | newest]

Thread overview: 3+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2019-08-30 04:19 PQconnectdbParams and encrypted password Dmitry Markman <[email protected]>
2019-08-30 13:50 ` Tom Lane <[email protected]>
2019-08-30 22:48   ` Dmitry Markman <[email protected]>

This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox