<div dir="ltr"><div dir="ltr"><br></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Thu, May 21, 2020 at 10:43 PM Tatsuo Ishii &lt;<a href="mailto:ishii@sraoss.co.jp">ishii@sraoss.co.jp</a>&gt; wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">&gt;&gt; &gt;&gt; I recommend you following:<br>
&gt;&gt;<br>
&gt;&gt; &gt;&gt; 0. enable allow_clear_text_frontend_auth.<br>
&gt;&gt;<br>
&gt; I wounder whether this is secure option to choose?<br>
&gt; <br>
&gt;&gt; &gt;&gt; 1. client&lt;=&gt;&gt; pgpool<br>
&gt;&gt;<br>
&gt;&gt; &gt;&gt; Use SSL connection and clear text password authenticatoion. You don&#39;t<br>
&gt;&gt; need to set up pool_passwd. Password will be provided by client.<br>
&gt;&gt;<br>
&gt;&gt; &gt;&gt; 2. pgppol &lt;=&gt; postgres<br>
&gt;&gt;<br>
&gt;&gt; &gt;&gt;Use SSL connection and md5 or SCRAM authenticatoion. The password used<br>
&gt;&gt; &gt;&gt;for the authentication is provided by client if<br>
&gt;&gt; &gt;&gt;allow_clear_text_frontend_auth is enabled.<br>
&gt;&gt;<br>
&gt;&gt; I assume I can&#39;t avoid pool_passwd if I don&#39;t want to compromise on<br>
&gt; security.<br>
<br>&gt;&gt;&gt; Can you elaborate what is your security concern?<br></blockquote><div>That the password will be in plain text ( not encrypted )  and can be compromised. Or I am missing something here.</div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<br>
&gt; I have tested below- could you please validate?<br>
&gt; 1- Create server and client certs<br>
&gt; 2- Update pgpool.conf ( using master slave mode)<br>
&gt;        ssl=on<br>
&gt;     ssl_key = &#39;/database11/ssl/erver.key&#39;<br>
&gt;     ssl_cert = &#39;/database11/ssl/server.crt<br>
&gt;     ssl_ca_cert = &#39;/database11/ssl/root.crt&#39;<br>
&gt;     pool_passwd = &#39;pool_passwd&#39;<br>
&gt; <br>
&gt;   3- Updated postgresql.conf<br>
&gt;        ssl=on<br>
&gt;     ssl_key = &#39;/database11/ssl/erver.key&#39;<br>
&gt;     ssl_cert = &#39;/database11/ssl/server.crt<br>
&gt;     ssl_ca_cert = &#39;/database11/ssl/root.crt&#39;<br>
&gt; <br>
&gt;     4- Updated pg_hba.conf<br>
&gt;     host postgres postgres md5<br>
&gt;     host postgres pgpool IP trust  ## pgpool- health check user<br>
&gt; <br>
&gt; 5- Restart whole setup.<br>
&gt; 6- Test<br>
&gt; <br>
&gt;    1. connect via psql using pgpool port --&gt; Successful and using SSL<br>
&gt;    connection<br>
&gt; <br>
&gt; # psql -U postgres -d postgres -p 8888<br>
&gt; Password for user postgres:<br>
&gt; psql (11.6)<br>
&gt; SSL connection (protocol: TLSv1.2, cipher: AES256-GCM-SHA384, bits: 256,<br>
&gt; compression: off)<br>
&gt; Type &quot;help&quot; for help.<br>
&gt; postgres=&gt; \c<br>
&gt; SSL connection (protocol: TLSv1.2, cipher: AES256-GCM-SHA384, bits: 256,<br>
&gt; compression: off)<br>
&gt; You are now connected to database &quot;postgres&quot; as user &quot;postgres&quot;.<br>
&gt; postgres=&gt;<br>
&gt; <br>
&gt; *Postgres log:*<br>
&gt;  LOG:  connection authorized: user=postgres database=postgres SSL enabled<br>
&gt; (protocol=TLSv1.2, cipher=ECDHE-RSA-AES256-GCM-SHA384, bits=256,<br>
&gt; compression=off)<br>
&gt; <br>
&gt;              2. Connect using PGAdmin<br>
&gt; client&lt;==&gt; pgpool : client certificate + md5 password<br>
&gt; pgpool&lt;==&gt;postgres : SSL + md5 password<br>
&gt; <br>
&gt; *pgpool logs: *<br>
&gt; [image: image.png]<br>
<br>&gt;&gt;&gt; I think it works as I expected.<br>
Great!<br></blockquote><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
&gt; *Some further questions: *<br>
&gt; -  Should healthcheck user ( pgpool ) be authenticating as either plain<br>
&gt; password in pgpool.conf  or trust in pg_hba.conf?<br>
&gt;   I assume if pool_passwd is enabled , then pgpool should use md5 password<br>
&gt; for backend authentication or it needs to be trust<br>
<br>&gt;&gt;&gt;Actually you can use plain text password, md5 password or AES256-CBC<br>&gt;&gt;&gt; encrypted password in health_check_password. AES256-CBC is most secure<br>&gt;&gt;&gt; but If you prefer md5 password, yes, you need to set md5<br>&gt;&gt;&gt; authentication in pg_hba.conf. Plain text and AES256 do not have such<br>&gt;&gt;&gt; a restriction.<br>
<br></blockquote><div>I tried AES password for healthcheck user and it worked . Thanks </div><div><br></div><div>But when I am trying to login via psql (using pgpool user) , it is giving me belwo error. 

I tried using pool_password file ( pgpool:AESxxxxx)  as well but no luck.

</div><div><font face="monospace"># psql -p 9999-h hostname -U pgpool</font><br>psql: ERROR:  unable to read message length<br>DETAIL:  message length (23) in slot 1 does not match with slot 0(42)<br>ERROR:  unable to read message length<br>DETAIL:  message length (23) in slot 1 does not match with slot 0(42)<br></div><div><br></div><div><b><u>Pgpool log:</u></b><br>2020-05-22 16:24:54: pid 11774: ERROR:  unable to read message length<br>2020-05-22 16:24:54: pid 11774: DETAIL:  message length (23) in slot 1 does not match with slot 0(42)<br></div><div><font color="#ff0000">* All users who has md5 password and is has entry in pool_passwd file are logging successfully( using psql and pgpool) but problem is with user having SCRAM password.</font><br></div><div><br></div><div>Questions: <br></div><div>- What am I doing wrong in above step?<br>- What are the steps , if I need to use combination of md5 and SCRAM passwords?<br>- when do I need to use pool_hba?</div><div>- Is it true that pool_passwd file works only for md5 passwords?  If yes, then how users with SCRAM password enabled will be able to connect using pgpool?</div><div><br></div><div></div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">&gt;&gt;&gt;A password in pool_passwd is used if health_check_password is an empty<br>&gt;&gt;&gt;string.<br>
<br>
&gt; - Some Detail msg in pgpool log that I an mot sure of  ?   what is server<br>
&gt; here ( pgpool or postgres) - server doesn&#39;t want to talk SSL<br>
&gt; 2020-05-21 19:16:20: pid 6664: DEBUG:  authenticate backend: key data<br>
&gt; received<br>
&gt; 2020-05-21 19:16:20: pid 6664: DEBUG:  authenticate backend: transaction<br>
&gt; state: I<br>
&gt; 2020-05-21 19:16:20: pid 6664: DEBUG:  attempting to negotiate a secure<br>
&gt; connection<br>
&gt; 2020-05-21 19:16:20: pid 6664: DETAIL:  sending client-&gt;server SSL request<br>
&gt; 2020-05-21 19:16:20: pid 6664: DEBUG:  attempting to negotiate a secure<br>
&gt; connection<br>
&gt; 2020-05-21 19:16:20: pid 6664: DETAIL:  client-&gt;server SSL response: N<br>
&gt; 2020-05-21 19:16:20: pid 6664: DEBUG:  attempting to negotiate a secure<br>
&gt; connection<br>
&gt; 2020-05-21 19:16:20: pid 6664: DETAIL:  *server doesn&#39;t want to talk SSL*<br>
&gt; 2020-05-21 19:16:20: pid 6664: DEBUG:  authenticate kind = 0<br>
<br>&gt;&gt;&gt; &quot;server&quot; means PostgreSQL here.<br>
Thanks <br></blockquote><div>What is the meaning of this message ? server doesn&#39;t want to talk SSL</div><div><br></div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
Best regards,<br>
--<br>
Tatsuo Ishii<br>
SRA OSS, Inc. Japan<br>
English: <a href="http://www.sraoss.co.jp/index_en.php" rel="noreferrer" target="_blank">http://www.sraoss.co.jp/index_en.php</a><br>
Japanese:<a href="http://www.sraoss.co.jp" rel="noreferrer" target="_blank">http://www.sraoss.co.jp</a><br>
</blockquote></div></div>