Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kDolq-00022x-Tg for pgsql-general@arkaria.postgresql.org; Thu, 03 Sep 2020 12:55:19 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1kDolp-0003Om-Qk for pgsql-general@arkaria.postgresql.org; Thu, 03 Sep 2020 12:55:17 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kDolp-0003Od-7N for pgsql-general@lists.postgresql.org; Thu, 03 Sep 2020 12:55:17 +0000 Received: from sonic314-20.consmr.mail.ne1.yahoo.com ([66.163.189.146]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1kDolk-0006sL-DG for pgsql-general@postgresql.org; Thu, 03 Sep 2020 12:55:16 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=verizon.net; s=a2048; t=1599137709; bh=hVGH4zcJTtvigXy2X45sl96hFYGLueIbMcKiqWq45nQ=; h=Date:From:Reply-To:To:Cc:In-Reply-To:References:Subject:From:Subject; b=EFED6h2BWx61J5BQcPn31qd2U5Orfdaj7rLR6Vdg4v+6OgsnWkfPoZOzaIAiiWf1T2Y+/b2leW5Ym2Q0KpnmkSZ7wFw5nYbpqXLusDYXzzANXwwJbWGJ45t7TUm81K0l6mhYJMnFs3WtzZdSBcP0bsqC/cN5/zxVV5g+bozUyybewWvNw13Ec1wdpG2jKPKi4twdWQ38W7iprHTkKzn9Jxh25W+9MP+8ig7jZbPQplWPgU+0oWu3dzclGhKHpYXD57obidcw8tUM1RaMMy1KBuphyOQK84sXaIMNfgri2/Ma9NS+mS6VS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7MJN rGfD07vhe3B.0WHqqchf8zJoeOfOSl9UTaBjowew5ZBJze3fYMv01eNwKofAI2RDiZhJ4UG8U4TD rsq.R_HFRUL8AUj_cEp1UQDkMqqHxz5pdVGRKH0v7gLKIyUngGxx_ECP5sogUfmCy9kFOcx9LtWz SOhnhx5Iex7n.j68V.tdXsQC9btnDAtrCfK4TsNcFo6vC_7x4HPM4lTH_yE54RsBadSMxe.7yf7y IyHQXSR2xi4TkPFaJOT9EHWmXzC3gD1MSxGZdSd3nvFbRClBse6oDNlLstww8aESAOFn8UTzNPum ND4T4hnzSc5M9Q0wjp_v.73tOeBySBJCeHD.RhkZcsXweu_klaFnl6W7LfGE1WFdjtY._Si7Ey0. F5_jab8GKf8KRXWH0Z0aoheO6KmrKArfCilGi9F7gIB_3IjjYJkRYgcYLtobcfLvGWWaDxf42BrC VNOqA.1zODFuuMMAvWmOT_HfD654LDts- Received: from sonic.gate.mail.ne1.yahoo.com by sonic314.consmr.mail.ne1.yahoo.com with HTTP; Thu, 3 Sep 2020 12:55:09 +0000 Date: Thu, 3 Sep 2020 12:55:08 +0000 (UTC) From: Susan Joseph Reply-To: Susan Joseph To: "sfrost@snowman.net" Cc: "pgsql-general@postgresql.org" Message-ID: <1878379566.2669355.1599137708587@mail.yahoo.com> In-Reply-To: <20200903122856.GL29590@tamriel.snowman.net> References: <976526972.6642745.1598278223530.ref@mail.yahoo.com> <976526972.6642745.1598278223530@mail.yahoo.com> <20200903122856.GL29590@tamriel.snowman.net> Subject: Re: SSL between Primary and Seconday PostgreSQL DBs MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_Part_2669354_1805399127.1599137708585" X-Mailer: WebService/1.1.16565 aolwebmail Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:79.0) Gecko/20100101 Firefox/79.0 Content-Length: 12701 List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk ------=_Part_2669354_1805399127.1599137708585 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable This is great, thanks.=C2=A0 I have not heard of verify-full but I will try= that and let you know if I have issues. So I will remove the passfile info for recovery.conf.=C2=A0 It was there be= cause I first set it up using passwords to make sure it was working and the= n moved to SSL so if not needed I can remove it. So if I don't put clientcert=3D1 do I just leave it at cert or should it be= set to something else? I will try and drop the other connection lines in the pg_hba.conf but I tho= ught the last time I did that it through an error.=C2=A0 Let me try it agai= n and see if it works. So are you saying that "sslmode=3Dverify-ca" doesn't actually verify that t= he certificate is from a CA it trusts?=C2=A0=20 So my big question is:=C2=A0 am I really adding more security by turning on= SSL or is it just more work for the DBA?=C2=A0=20 =20 =20 Susan Joseph sandajoseph@verizon.net =20 =20 -----Original Message----- From: Stephen Frost To: Susan Joseph Cc: pgsql-general@postgresql.org Sent: Thu, Sep 3, 2020 8:28 am Subject: Re: SSL between Primary and Seconday PostgreSQL DBs Greetings, * Susan Joseph (sandajoseph@verizon.net) wrote: >=C2=A0 =C2=A0 - primary_conninfo =3D 'user=3Drep_user passfile=3D''/data/.= pgpass'' host=3D port=3D5432 sslmode=3Dverify-ca sslcert=3Dc= lient.crt sslkey=3Dclient.key sslcompression=3D0 target_session_attrs=3Dany= ' You really should be using sslmode=3Dverify-full, otherwise any certificate signed by a trusted CA on the server side is accepted. Also, you shouldn't really need to pass in 'passfile' above... >=C2=A0 =C2=A0 - On the Secondary I edit the pg_hba.conf file and change th= e rep_user line to: >=C2=A0 =C2=A0=20 >=C2=A0 =C2=A0 - hostssl=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0 replication=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 rep_user=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 /32= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 cert clientcert=3D1 Saying clientcert=3D1 when using cert auth really shouldn't be needed. > My questions are:=C2=A0=20 >=C2=A0 =C2=A0 - Do I need to set the information in the Secondary postgres= ql.conf?=C2=A0 Originally I did not set this and everything worked but I sa= w errors in my log files that said to do SSL these needed to be set so I we= nt back and set them.=C2=A0 Are there pgsql commands I can run to test that= my SSL is working in both directions?=C2=A0=20 The only connection you're talking about here is from the secondary to the primary and for that you just need the primary_conninfo settings for the secondary set up correctly and the SSL settings on the primary. However, if you want people to be able to make SSL connections to the secondary, then you need to configure SSL on the secondary. As for testing the connection, see the pg_stat_ssl view. >=C2=A0 =C2=A0 - Are my pg_hba.conf files set correctly?=C2=A0 Is that how = you get SSL "turned on" for communications between the primary and the rep_= user account? 'hostssl' will only match an incoming connection if it's being made over SSL.=C2=A0 As long as you don't have anything else in your pg_hba.conf, the= n only SSL connections will be allowed.=C2=A0 However, first entry in the pg_hba.conf matches, so if you have earlier entries, those might be getting used instead. >=C2=A0 =C2=A0 - If I leave my key file encrypted then every time my databa= ses have to be started have to enter the password.=C2=A0 So you can either = leave the passwords unencrypted and set the permissions on the file to 0600= accessible only by postgres or you can enter the key password each time th= e database is started up.=C2=A0 As someone in the security field I have a t= ough time leaving the key unencrypted but as some setting up a production s= ystem that is located on a network that you can't get to without directly a= ccessing the server I feel that is enough security that I can leave them un= encrypted.=C2=A0 Thoughts? You could use a vaulting system to pull the key and make it available at startup and then remove it after, perhaps, but I would suggest that it's pretty common to have SSL keys unencrypted on systems which are doing SSL and otherwise secured. >=C2=A0 =C2=A0 - Am I missing anything?=C2=A0 There are no videos out there= that show how to stand up a 2 way SSL communication channel between the pr= imary and secondary, or does anyone have one that they can share? Unfortunately, there's definitely areas here where we could, and really should, improve when it comes to logging exactly what validation has been done on incoming connections, to provide the kind of reassurance you're looking for.=C2=A0 Things like the difference between verify-ca and verify-full aren't really very well explained, particularly since it's very uncommon, in my experience, for people who have used SSL/TLS in other places to have any concept of "verify-ca" since it's basically "don't actually verify that the other side is who they claim to be".. Thanks, Stephen ------=_Part_2669354_1805399127.1599137708585 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable
This is great, thanks.  I have not heard of veri= fy-full but I will try that and let you know if I have issues.

So I will remove the passfile info for recovery.conf.=   It was there because I first set it up using passwords to make sure = it was working and then moved to SSL so if not needed I can remove it.

So if I don't put clientcert=3D1 do I just leave it a= t cert or should it be set to something else?

I will try and drop the other connection lines in the= pg_hba.conf but I thought the last time I did that it through an error.&nb= sp; Let me try it again and see if it works.

So are you saying that "sslmode=3Dverify-ca" doesn't actually verify that the certifica= te is from a CA it trusts? 

So my big question is:  am I really adding more = security by turning on SSL or is it just more work for the DBA? 




Susan Joseph
sandajoseph@verizon.net


-----= Original Message-----
From: Stephen Frost <sfrost@snowman.net>
To: Susan Joseph <sandajoseph@verizon.net>
Cc: pgsql-general@postgresql.org <pgsql-general@postgresql.org>
Sent: Thu, Sep 3, 2020 8:28 am
Subject: Re: SSL between Primary and Seconday PostgreSQL DBs

Greetings,

* Susan Joseph (sandajoseph@verizon.net) wrote:
>&n= bsp;   - primary_conninfo =3D 'user=3Drep_user passfile=3D''/data/.pgp= ass'' host=3D<Primary DB IP> port=3D5432 sslmode=3Dverify-ca sslcert= =3Dclient.crt sslkey=3Dclient.key sslcompression=3D0 target_session_attrs= =3Dany'

You really should be using ssl= mode=3Dverify-full, otherwise any
certificate signed by a= trusted CA on the server side is accepted.

Also, you shouldn't really need to pass in 'passfile' above...

>    - On the Secondary I edit = the pg_hba.conf file and change the rep_user line to:
>= ;   
>    - hostssl  &n= bsp;       replication    = ;     rep_user       = ;    <primary IP>/32      cer= t clientcert=3D1

Saying clientcert=3D1= when using cert auth really shouldn't be needed.

> My questions are: 
>  &nb= sp; - Do I need to set the information in the Secondary postgresql.conf?&nb= sp; Originally I did not set this and everything worked but I saw errors in= my log files that said to do SSL these needed to be set so I went back and= set them.  Are there pgsql commands I can run to test that my SSL is = working in both directions? 

Th= e only connection you're talking about here is from the secondary to
the primary and for that you just need the primary_conninfo set= tings for
the secondary set up correctly and the SSL sett= ings on the primary.
However, if you want people to be ab= le to make SSL connections to the
secondary, then you nee= d to configure SSL on the secondary.

A= s for testing the connection, see the pg_stat_ssl view.
<= br clear=3D"none">>    - Are my pg_hba.conf files set correctl= y?  Is that how you get SSL "turned on" for communications between the= primary and the rep_user account?

'ho= stssl' will only match an incoming connection if it's being made over
SSL.  As long as you don't have anything else in your pg_= hba.conf, then
only SSL connections will be allowed. = ; However, first entry in the
pg_hba.conf matches, so if = you have earlier entries, those might be
getting used ins= tead.

>    - If I leave m= y key file encrypted then every time my databases have to be started have t= o enter the password.  So you can either leave the passwords unencrypt= ed and set the permissions on the file to 0600 accessible only by postgres = or you can enter the key password each time the database is started up.&nbs= p; As someone in the security field I have a tough time leaving the key une= ncrypted but as some setting up a production system that is located on a ne= twork that you can't get to without directly accessing the server I feel th= at is enough security that I can leave them unencrypted.  Thoughts?
You could use a vaulting system to pull = the key and make it available at
startup and then remove = it after, perhaps, but I would suggest that it's
pretty c= ommon to have SSL keys unencrypted on systems which are doing
SSL and otherwise secured.

>&n= bsp;   - Am I missing anything?  There are no videos out there th= at show how to stand up a 2 way SSL communication channel between the prima= ry and secondary, or does anyone have one that they can share?

Unfortunately, there's definitely areas here where= we could, and really
should, improve when it comes to lo= gging exactly what validation has
been done on incoming c= onnections, to provide the kind of reassurance
you're loo= king for.  Things like the difference between verify-ca and
verify-full aren't really very well explained, particularly since= it's
very uncommon, in my experience, for people who hav= e used SSL/TLS in
other places to have any concept of "ve= rify-ca" since it's basically
"don't actually verify that= the other side is who they claim to be"..


Thanks,


Stephen
------=_Part_2669354_1805399127.1599137708585--