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 1kDoMS-0000j6-CS for pgsql-general@arkaria.postgresql.org; Thu, 03 Sep 2020 12:29:04 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1kDoMQ-0003RR-TV for pgsql-general@arkaria.postgresql.org; Thu, 03 Sep 2020 12:29:02 +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 1kDoMQ-0003RK-LG for pgsql-general@lists.postgresql.org; Thu, 03 Sep 2020 12:29:02 +0000 Received: from tamriel.snowman.net ([96.255.250.162]) by magus.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1kDoMN-0006eP-DK for pgsql-general@postgresql.org; Thu, 03 Sep 2020 12:29:01 +0000 Received: by tamriel.snowman.net (Postfix, from userid 1000) id 81BC25F79F; Thu, 3 Sep 2020 08:28:56 -0400 (EDT) Date: Thu, 3 Sep 2020 08:28:56 -0400 From: Stephen Frost To: Susan Joseph Cc: "pgsql-general@postgresql.org" Subject: Re: SSL between Primary and Seconday PostgreSQL DBs Message-ID: <20200903122856.GL29590@tamriel.snowman.net> References: <976526972.6642745.1598278223530.ref@mail.yahoo.com> <976526972.6642745.1598278223530@mail.yahoo.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="wjf6QCDC/Xtrnnlm" Content-Disposition: inline In-Reply-To: <976526972.6642745.1598278223530@mail.yahoo.com> User-Agent: Mutt/1.5.24 (2015-08-30) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk --wjf6QCDC/Xtrnnlm Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Greetings, * Susan Joseph (sandajoseph@verizon.net) wrote: > - primary_conninfo =3D 'user=3Drep_user passfile=3D''/data/.pgpass'' h= ost=3D port=3D5432 sslmode=3Dverify-ca sslcert=3Dclient.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... > - On the Secondary I edit the pg_hba.conf file and change the rep_user= line to: > =20 > - hostssl=A0=A0=A0=A0=A0=A0=A0=A0=A0 replication=A0=A0=A0=A0=A0=A0=A0= =A0 rep_user=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 /32=A0=A0=A0=A0=A0 c= ert clientcert=3D1 Saying clientcert=3D1 when using cert auth really shouldn't be needed. > My questions are: =20 > - Do I need to set the information in the Secondary postgresql.conf?= =A0 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.=A0 Are there pgsql commands I can run to test that my SSL is wor= king in both directions? =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. > - Are my pg_hba.conf files set correctly?=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. 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 instead. > - If I leave my key file encrypted then every time my databases have t= o be started have to enter the password.=A0 So you can either leave the pas= swords unencrypted and set the permissions on the file to 0600 accessible o= nly by postgres or you can enter the key password each time the database is= started up.=A0 As someone in the security field I have a tough time leavin= g the key unencrypted but as some setting up a production system that is lo= cated on a network that you can't get to without directly accessing the ser= ver I feel that is enough security that I can leave them unencrypted.=A0 Th= oughts? 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. > - Am I missing anything?=A0 There are no videos out there that show ho= w to stand up a 2 way SSL communication channel between the primary and sec= ondary, 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. 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 --wjf6QCDC/Xtrnnlm Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v1 iQIcBAEBCgAGBQJfUOGIAAoJEO1sijiDR2RV/5cP/2e65/YfCxkU5zXv8MBLVcbM kPZh2kk94JHlkTyeYTUp9AxcvHHYR48gqvqzMUnoKrA3ykjQNE47n+FPpq9YxGh7 wnb6P2lYh0bQ/Ee86ODSa9EXJPxcsQMhfwk9j9wea2JKhBCJSHmgtTx2XKJxDhkm 6o2KZUAXW+3wqXyqtrLZCdX6h7VRQiE7EztFfn6TOgLl5sN0NJD7swxZ9aiNDWCQ RdETpyQ6Sxx5oei9ueS8gDRClSVEB6QivfiWaX2ZPs8ltDKH/ddVm67OeeZvgY1c H4+k0PTA5OCiSVLjBR7kvtyQJqmGs+nS35MkO/qkvFGY444+SH+xI9JT6RP0I4Jk bhVqyCAYV8JVN3+mbY+QbN1Uc9ikf9oOL2PwzJNtVqDsoyX+E9BYGoiFbVHj0mw0 iBKPxLwt99Lt7l3rWjSDk9ouUFmI3RnQ9N8cHM+52Kc/VrHDVGU6E8bdLVQWpobq TMbG+hGZEQ/DMT8Ks0snrcBEm/bbEn2SLQnOYD4ZS+KyK8G3tKlmDbG0VtCqY608 XpFvOTj8qpPdnVGXtA/LIaLIPq5L57f0gTsVRgyxknQ6cn5Rd6dde83FBsZydkGa BQPiGVQ9lx3M5CThzEitRb5HyeKL130VGEL2uV7QHNRIgUK5j0HR8dBb9/R3EhoS Tv64d0qLJ7CJiKXXrcjW =0oIe -----END PGP SIGNATURE----- --wjf6QCDC/Xtrnnlm--