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 1kDhNU-00034J-1X for pgsql-general@arkaria.postgresql.org; Thu, 03 Sep 2020 05:01:40 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1kDhNT-0003Oy-01 for pgsql-general@arkaria.postgresql.org; Thu, 03 Sep 2020 05:01:39 +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 1kDhNS-0003Or-N9 for pgsql-general@lists.postgresql.org; Thu, 03 Sep 2020 05:01:38 +0000 Received: from [64.147.123.35] (helo=wforward5-smtp.messagingengine.com) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kDhNM-0002c8-Vb for pgsql-general@postgresql.org; Thu, 03 Sep 2020 05:01:36 +0000 Received: from compute1.internal (compute1.nyi.internal [10.202.2.41]) by mailforward.west.internal (Postfix) with ESMTP id 41EC7A3C; Thu, 3 Sep 2020 01:01:20 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute1.internal (MEProxy); Thu, 03 Sep 2020 01:01:20 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=content-transfer-encoding:content-type :date:from:in-reply-to:message-id:mime-version:references :subject:to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender :x-sasl-enc; s=fm3; bh=p9MGC7pd25+ER3jLwzelV+9GVij+SPYuVhAMSjub+ c0=; b=XPsZiaBszAN7UNmeVKtIUspqZ0V3ki3S+Clcd58CUB3v5TdgmSeUckoRl ICsUbuEzsRmmxFh5ZfH37JrdYhe3C16+WT4iF9CXsaYhDiw7tS8+Jzv1b3HhSbEx mSqp9AOc+dPrut6BzpD03igmGAQExE/urVJID9GBNqE5RFdr6yXrVlWjxEzloCkR LerETMy2r6Yeq07VBpK7t3SIQIKCyFAYhH+Cctl29B19x0sGMbjhZ+LIF+9Qz2Rp unPHVJCpMzUmha3VD51mnareNwdE5yfW67MSY18my0XpxLcqDizvgeqOMWjqbfyp tHxgshEmgTGAs+TlY+mdTzlqyBWYA== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduiedrudegtddgkeelucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhepuffvfhfhohfkffgfgggjtgfgsehtkeertddtfeejnecuhfhrohhmpefrvght vghrucfgihhsvghnthhrrghuthcuoehpvghtvghrrdgvihhsvghnthhrrghuthesvdhnug hquhgrughrrghnthdrtghomheqnecuggftrfgrthhtvghrnhepleffffetffejfefhheff veekieetieekudeffffhheevieelhfethfegfeduhedtnecuffhomhgrihhnpedvnhguqh hurggurhgrnhhtrdgtohhmnecukfhppeekjedrudejjedrjeejrdeltdenucevlhhushht vghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpehpvghtvghrrdgvihhsvg hnthhrrghuthesvdhnughquhgrughrrghnthdrtghomh X-ME-Proxy: Received: from april.pezone.net (p57b14d5a.dip0.t-ipconnect.de [87.177.77.90]) by mail.messagingengine.com (Postfix) with ESMTPA id 0C5EA328005D; Thu, 3 Sep 2020 01:01:18 -0400 (EDT) Subject: Re: SSL between Primary and Seconday PostgreSQL DBs To: Susan Joseph , "pgsql-general@postgresql.org" References: <976526972.6642745.1598278223530.ref@mail.yahoo.com> <976526972.6642745.1598278223530@mail.yahoo.com> <347470685.8377276.1598525839866@mail.yahoo.com> From: Peter Eisentraut Organization: 2ndQuadrant Message-ID: Date: Thu, 3 Sep 2020 07:01:17 +0200 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.14; rv:52.0) Gecko/20100101 Thunderbird/52.9.1 MIME-Version: 1.0 In-Reply-To: <347470685.8377276.1598525839866@mail.yahoo.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 8bit X-Host-Lookup-Failed: Reverse DNS lookup failed for 64.147.123.35 (deferred) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On 2020-08-27 12:57, Susan Joseph wrote: > So has no one done this before? I'm sure people have done this. But I suggest that if you ask a question on this mailing list, you ask something more concrete, like, I tried to do this, and got stuck here, and tried this and got this error. People can help with that sort of thing. What we have here is a complex security setup and you are asking people to do an open-ended review. No one wants to do that. > -----Original Message----- > From: Susan Joseph > To: pgsql-general@postgresql.org > Sent: Mon, Aug 24, 2020 10:10 am > Subject: SSL between Primary and Seconday PostgreSQL DBs > > I have setup a Primary and Secondary PostgreSQL DBs.  They were setup up > with basic replication then I went back and modified them to use SSL.  I > am just not sure if I did it correctly.  Everything is working but I > want to make sure I have the settings correctly.  I am using PostgreSQL > 11.2. > > * I have a PKI that I stood up so I issued 2 server certificates one > for each database from my CA. > * Primary server certificate - Primary Database > o The FQDN and IP address are set in the SAN field. > o FQDN is also the CN in the DN > o Key Usage is set to Digital Signature and Key encipherment > o EKU is set to Server Authentication and Client Authentication > * Rep_user certificate - Secondary Database > o CN is set to the rep_user account name > o Key Usage is set to digital signature and key encipherment > o EKU is set to client authentication > * Each certificate file contains the certificate and the subCA > certificate who issued the certificate and put in a file called > server.crt for the Primary and client.crt for the secondary. > * The key for each certificate is stored in a separate file > unencrypted (I have questions about this later on) in a file called > server.key and client.key > * The server.crt, server.key, and root.crt are put onto the primary > database server in the /data/pgsql/data location, the owner and > group of these files is set to postgres > * The client.crt, client.key, and root.crt are put onto the primary > database server in the /data/pgsql/data location, the owner and > group of these files is set to postgres > * On the Primary in postgresql.conf I set: > o ssl=on > o ssl_ca_file='root.crt' > o ssl_cert_file='server.crt' > o ssl_key_file='server.key' > o ssl_ciphers='HIGH:MEDIUM:+3DES:!aNULL' > * On the Primary in pg_hba.conf I add a replication line: > o hostssl                        replication > rep_user                  cert > * On the Secondary I set the following information in the > postgresql.conf to:  (DO I NEED TO DO THIS??) > o ssl=on > o ssl_ca_file='root.crt' > o ssl_cert_file='client.crt' > o ssl_cert_fkey='client.key' > o ssl_ciphers='HIGH:MEDIUM:+3DES:!aNULL' > * On the Secondary I edit the recovery.conf file to the following: > o primary_conninfo = 'user=rep_user passfile=''/data/.pgpass'' > host= port=5432 sslmode=verify-ca > sslcert=client.crt sslkey=client.key sslcompression=0 > target_session_attrs=any' > * On the Secondary I edit the pg_hba.conf file and change the rep_user > line to: > o hostssl          replication         rep_user           IP>/32      cert clientcert=1 > * On the Secondary I move the root.crt to /data/pgsql/data/.postgresql > * Then I restart the databases > > > My questions are: > > * Do I need to set the information in the Secondary postgresql.conf? > 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? > * Are my pg_hba.conf files set correctly?  Is that how you get SSL > "turned on" for communications between the primary and the rep_user > account? > * If I leave my key file encrypted then every time my databases have > to be started have to enter the password.  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 the database is started up.  As someone in the security > field I have a tough time leaving the key unencrypted but as some > setting up a production system that is located on a network that you > can't get to without directly accessing the server I feel that is > enough security that I can leave them unencrypted.  Thoughts? > * Am I missing anything?  There are no videos out there that show how > to stand up a 2 way SSL communication channel between the primary > and secondary, or does anyone have one that they can share? > > > Thanks, >   Susan > > > -- Peter Eisentraut http://www.2ndQuadrant.com/ PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services