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 1kDmtE-0004Cq-UT for pgsql-general@arkaria.postgresql.org; Thu, 03 Sep 2020 10:54:49 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1kDmtC-0001P7-Ky for pgsql-general@arkaria.postgresql.org; Thu, 03 Sep 2020 10:54:46 +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 1kDmtB-0001P0-Qr for pgsql-general@lists.postgresql.org; Thu, 03 Sep 2020 10:54:46 +0000 Received: from sonic317-34.consmr.mail.ne1.yahoo.com ([66.163.184.45]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1kDmt7-0005n6-O2 for pgsql-general@postgresql.org; Thu, 03 Sep 2020 10:54:45 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=verizon.net; s=a2048; t=1599130478; bh=tNN+GSno3UaWTdM8OIsDbBFnit77oj70qy6UYCjOYj0=; h=Date:From:Reply-To:To:In-Reply-To:References:Subject:From:Subject; b=mD9ct4P+1YfTdkWFPBpdmQ3nFjyxYQa8qz1isbxuy1yU72OsRHfOldXZprBdpbKQzulJvfe7wlX15GguGY4tZ1BAr2qJBzlax8e3bN/FUUPh38+kNJOoogAkeN+i1bpRYnqA3nXxRAzM23yKCropRkFhFeb6OxERYzL/eV3LCHbCgcOJKS9eRvk0nc/jTRkLd0xiqD9nK36D7icm2zjFz6eyQUNxk7BXHzbFNAknag1LWKE3d5Yp3tc7Ke5+lxOdK6GwgUhaBVzLRijobRKqclHav8LObohDFabhMBV6+l2zCxMneZaKxpbyrA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JvZzGK5tWDOQP8gFUeV gWS48uiKR1EwmFlWsxmMk5OwrcfnvOkRN4Tu9z49IhXsHnt_nthQcyNmPDgO_7khTuORATBPcGtL XVz9U0KYBWCGbmR0nqcTcpX5s_judQqI49vdNuiUmE6lEOGo9SeH1z4H7KqW.55KdDyddIxDSL0k JzOWIeQa95L4B3frLqjdsv8LTG7Ct_rvJXIygFE_uJAbgD__30NUDI5Dg26silylNbsyRWDUIKFJ d9lH7xjergThv7_R9ifaEaPqH4LR78_7MK_vQwnVJ14GqqdWDcIdOMzUf1m3Otr05OwK3Mnt7b4F 0Pw1v1OJJn.yyQhsMcMt5_reTD_bB3iooUBsFtZK6D_D1jMCLIOQBwZmDdPjsCysQVqea27Sldtl 3I1Fp4bC39MseoYufvnRqFySwHdC3K9OD8iicnGluai18FpGv_txtif8dKE_6BsZaaaZqvnbRUBV CsHoAGn_KLv3pRw-- Received: from sonic.gate.mail.ne1.yahoo.com by sonic317.consmr.mail.ne1.yahoo.com with HTTP; Thu, 3 Sep 2020 10:54:38 +0000 Date: Thu, 3 Sep 2020 10:54:36 +0000 (UTC) From: Susan Joseph Reply-To: Susan Joseph To: "peter.eisentraut@2ndquadrant.com" , "pgsql-general@postgresql.org" Message-ID: <845624022.192753.1599130476553@mail.yahoo.com> In-Reply-To: References: <976526972.6642745.1598278223530.ref@mail.yahoo.com> <976526972.6642745.1598278223530@mail.yahoo.com> <347470685.8377276.1598525839866@mail.yahoo.com> Subject: Re: SSL between Primary and Seconday PostgreSQL DBs MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_Part_192752_1073066171.1599130476551" X-Mailer: WebService/1.1.16583 aolwebmail Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:79.0) Gecko/20100101 Firefox/79.0 Content-Length: 18399 List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk ------=_Part_192752_1073066171.1599130476551 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable OK, I understand I was just hoping someone could confirm that my settings a= re correct.=C2=A0=20 I didn't come across an error so everything seems to be working I just can'= t verify that SSL is working.=C2=A0=20 Are there any commands you can run to verify that SSL is up and operational= ?=20 Testing from a client to the database doesn't prove that database to datab= ase is working.=C2=A0 =20 =20 Susan Joseph sandajoseph@verizon.net =20 =20 -----Original Message----- From: Peter Eisentraut To: Susan Joseph ; pgsql-general@postgresql.org Sent: Thu, Sep 3, 2020 1:01 am Subject: Re: SSL between Primary and Seconday PostgreSQL DBs On 2020-08-27 12:57, Susan Joseph wrote: > So has no one done this before? I'm sure people have done this.=C2=A0 But I suggest that if you ask a=20 question on this mailing list, you ask something more concrete, like, I=20 tried to do this, and got stuck here, and tried this and got this error.=20 =C2=A0 People can help with that sort of thing.=C2=A0 What we have here is = a=20 complex security setup and you are asking people to do an open-ended=20 review.=C2=A0 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 >=20 > I have setup a Primary and Secondary PostgreSQL DBs.=C2=A0 They were setu= p up=20 > with basic replication then I went back and modified them to use SSL.=C2= =A0 I=20 > am just not sure if I did it correctly.=C2=A0 Everything is working but I= =20 > want to make sure I have the settings correctly.=C2=A0 I am using Postgre= SQL=20 > 11.2. >=20 >=C2=A0 * I have a PKI that I stood up so I issued 2 server certificates on= e >=C2=A0 =C2=A0 for each database from my CA. >=C2=A0 * Primary server certificate - Primary Database >=C2=A0 =C2=A0 =C2=A0 o The FQDN and IP address are set in the SAN field. >=C2=A0 =C2=A0 =C2=A0 o FQDN is also the CN in the DN >=C2=A0 =C2=A0 =C2=A0 o Key Usage is set to Digital Signature and Key encip= herment >=C2=A0 =C2=A0 =C2=A0 o EKU is set to Server Authentication and Client Auth= entication >=C2=A0 * Rep_user certificate - Secondary Database >=C2=A0 =C2=A0 =C2=A0 o CN is set to the rep_user account name >=C2=A0 =C2=A0 =C2=A0 o Key Usage is set to digital signature and key encip= herment >=C2=A0 =C2=A0 =C2=A0 o EKU is set to client authentication >=C2=A0 * Each certificate file contains the certificate and the subCA >=C2=A0 =C2=A0 certificate who issued the certificate and put in a file cal= led >=C2=A0 =C2=A0 server.crt for the Primary and client.crt for the secondary. >=C2=A0 * The key for each certificate is stored in a separate file >=C2=A0 =C2=A0 unencrypted (I have questions about this later on) in a file= called >=C2=A0 =C2=A0 server.key and client.key >=C2=A0 * The server.crt, server.key, and root.crt are put onto the primary >=C2=A0 =C2=A0 database server in the /data/pgsql/data location, the owner = and >=C2=A0 =C2=A0 group of these files is set to postgres >=C2=A0 * The client.crt, client.key, and root.crt are put onto the primary >=C2=A0 =C2=A0 database server in the /data/pgsql/data location, the owner = and >=C2=A0 =C2=A0 group of these files is set to postgres >=C2=A0 * On the Primary in postgresql.conf I set: >=C2=A0 =C2=A0 =C2=A0 o ssl=3Don >=C2=A0 =C2=A0 =C2=A0 o ssl_ca_file=3D'root.crt' >=C2=A0 =C2=A0 =C2=A0 o ssl_cert_file=3D'server.crt' >=C2=A0 =C2=A0 =C2=A0 o ssl_key_file=3D'server.key' >=C2=A0 =C2=A0 =C2=A0 o ssl_ciphers=3D'HIGH:MEDIUM:+3DES:!aNULL' >=C2=A0 * On the Primary in pg_hba.conf I add a replication line: >=C2=A0 =C2=A0 =C2=A0 o hostssl=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=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=20 >=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=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 cert >=C2=A0 * On the Secondary I set the following information in the >=C2=A0 =C2=A0 postgresql.conf to:=C2=A0 (DO I NEED TO DO THIS??) >=C2=A0 =C2=A0 =C2=A0 o ssl=3Don >=C2=A0 =C2=A0 =C2=A0 o ssl_ca_file=3D'root.crt' >=C2=A0 =C2=A0 =C2=A0 o ssl_cert_file=3D'client.crt' >=C2=A0 =C2=A0 =C2=A0 o ssl_cert_fkey=3D'client.key' >=C2=A0 =C2=A0 =C2=A0 o ssl_ciphers=3D'HIGH:MEDIUM:+3DES:!aNULL' >=C2=A0 * On the Secondary I edit the recovery.conf file to the following: >=C2=A0 =C2=A0 =C2=A0 o primary_conninfo =3D 'user=3Drep_user passfile=3D''= /data/.pgpass'' >=C2=A0 =C2=A0 =C2=A0 =C2=A0 host=3D port=3D5432 sslmode=3Dv= erify-ca >=C2=A0 =C2=A0 =C2=A0 =C2=A0 sslcert=3Dclient.crt sslkey=3Dclient.key sslco= mpression=3D0 >=C2=A0 =C2=A0 =C2=A0 =C2=A0 target_session_attrs=3Dany' >=C2=A0 * On the Secondary I edit the pg_hba.conf file and change the rep_u= ser >=C2=A0 =C2=A0 line to: >=C2=A0 =C2=A0 =C2=A0 o 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 re= p_user=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 IP>/32=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 cert clie= ntcert=3D1 >=C2=A0 * On the Secondary I move the root.crt to /data/pgsql/data/.postgre= sql >=C2=A0 * Then I restart the databases >=20 >=20 > My questions are: >=20 >=C2=A0 * Do I need to set the information in the Secondary postgresql.conf= ?=20 >=C2=A0 =C2=A0 Originally I did not set this and everything worked but I sa= w errors >=C2=A0 =C2=A0 in my log files that said to do SSL these needed to be set s= o I went >=C2=A0 =C2=A0 back and set them.=C2=A0 Are there pgsql commands I can run = to test that >=C2=A0 =C2=A0 my SSL is working in both directions? >=C2=A0 * Are my pg_hba.conf files set correctly?=C2=A0 Is that how you get= SSL >=C2=A0 =C2=A0 "turned on" for communications between the primary and the r= ep_user >=C2=A0 =C2=A0 account? >=C2=A0 * If I leave my key file encrypted then every time my databases hav= e >=C2=A0 =C2=A0 to be started have to enter the password.=C2=A0 So you can e= ither leave >=C2=A0 =C2=A0 the passwords unencrypted and set the permissions on the fil= e to >=C2=A0 =C2=A0 0600 accessible only by postgres or you can enter the key pa= ssword >=C2=A0 =C2=A0 each time the database is started up.=C2=A0 As someone in th= e security >=C2=A0 =C2=A0 field I have a tough time leaving the key unencrypted but as= some >=C2=A0 =C2=A0 setting up a production system that is located on a network = that you >=C2=A0 =C2=A0 can't get to without directly accessing the server I feel th= at is >=C2=A0 =C2=A0 enough security that I can leave them unencrypted.=C2=A0 Tho= ughts? >=C2=A0 * Am I missing anything?=C2=A0 There are no videos out there that s= how how >=C2=A0 =C2=A0 to stand up a 2 way SSL communication channel between the pr= imary >=C2=A0 =C2=A0 and secondary, or does anyone have one that they can share? >=20 >=20 > Thanks, >=C2=A0 =C2=A0 Susan >=20 >=20 >=20 --=20 Peter Eisentraut=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 http://www= .2ndQuadrant.com/ PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services ------=_Part_192752_1073066171.1599130476551 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable
OK, I understand I was just hoping someone could conf= irm that my settings are correct. 
I didn't come across an error so everything seems to = be working I just can't verify that SSL is working. 
Are there any commands you can run to verify that SSL= is up and operational?
Testing from a client to the database doesn't prove = that database to database is working. 


Susan Joseph
sandajoseph@verizon.net


-----= Original Message-----
From: Peter Eisentraut <peter.eisentraut@2ndquadrant.com>
To: Susan Joseph <sandajoseph@verizon.net>; pgsql-general@postgresql.= org <pgsql-general@postgresql.org>
Sent: Thu, Sep 3, 2020 1:01 am
Subject: Re: SSL between Primary and Seconday PostgreSQL DBs

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 concret= e, like, I
tried to do this, and got stuck here, and tri= ed 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 J= oseph <sandajoseph@verizon.net>
> To: pgsql-general@postg= resql.org <pgsql-general@postgre= sql.org>
> Sent: Mon, Aug 24, 2020 10:10 am
> Subject: SSL between Primary and Seconday PostgreSQL DB= s
>
> 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.  E= verything is working but I
> want to make sure I have= the settings correctly.  I am using PostgreSQL
>= ; 11.2.
>
>  * I have a PK= I that I stood up so I issued 2 server certificates one
&= gt;    for each database from my CA.
> = ; * Primary server certificate - Primary Database
>&n= bsp;     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 Sig= nature and Key encipherment
>      o E= KU 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 signat= ure and key encipherment
>      o EKU = is set to client authentication
>  * Each certif= icate file contains the certificate and the subCA
>&nb= sp;   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 ce= rtificate 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 pri= mary
>    database server in the /data/pgsq= l/data location, the owner and
>    group o= f these files is set to postgres
>  * The client= .crt, client.key, and root.crt are put onto the primary
&= gt;    database server in the /data/pgsql/data location, the own= er and
>    group of these files is set to = postgres
>  * On the Primary in postgresql.conf = I set:
>      o ssl=3Don
>      o ssl_ca_file=3D'root.crt'
>      o ssl_cert_file=3D'server.crt'
>      o ssl_key_file=3D'server.key'
= >      o ssl_ciphers=3D'HIGH:MEDIUM:+3DES:!aNULL'
>  * On the Primary in pg_hba.conf I add a replication= line:
>      o hostssl  &nb= sp;            =          replication    &= nbsp;  
>        rep_user&= nbsp;           &nbs= p;     cert
>  * On the Seco= ndary I set the following information in the
>  &= nbsp; postgresql.conf to:  (DO I NEED TO DO THIS??)
>      o ssl=3Don
>    &= nbsp; o ssl_ca_file=3D'root.crt'
>     = ; o ssl_cert_file=3D'client.crt'
>     = ; o ssl_cert_fkey=3D'client.key'
>     = ; o ssl_ciphers=3D'HIGH:MEDIUM:+3DES:!aNULL'
>  = * On the Secondary I edit the recovery.conf file to the following:
>      o primary_conninfo =3D 'user=3Drep_use= r passfile=3D''/data/.pgpass''

> = ;       host=3D<Primary DB IP> port=3D5432 sslmode=3D= verify-ca
>        sslcert=3Dclie= nt.crt sslkey=3Dclient.key sslcompression=3D0
>  =       target_session_attrs=3Dany'
>&nb= sp; * On the Secondary I edit the pg_hba.conf file and change the rep_user=
>    line to:
> =     o hostssl        &n= bsp; replication         rep_user&n= bsp;          <primary
>        IP>/32   &= nbsp;  cert clientcert=3D1
>  * On the Seco= ndary 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?
>    Origin= ally I did not set this and everything worked but I saw errors
>    in my log files that said to do SSL these needed t= o be set so I went
>    back and set them.&= nbsp; 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 ge= t SSL
>    "turned on" for communications b= etween the primary and the rep_user
>    ac= count?
>  * If I leave my key file encrypted the= n every time my databases have
>    to be s= tarted have to enter the password.  So you can either leave
>    the passwords unencrypted and set the permissi= ons on the file to
>    0600 accessible onl= y by postgres or you can enter the key password
> = ;   each time the database is started up.  As someone in the sec= urity
>    field I have a tough time leavin= g the key unencrypted but as some
>    sett= ing up a production system that is located on a network that you
>    can't get to without directly accessing the se= rver I feel that is
>    enough security th= at I can leave them unencrypted.  Thoughts?
>&nbs= p; * Am I missing anything?  There are no videos out there that show = how
>    to stand up a 2 way SSL communicat= ion channel between the primary
>    and se= condary, or does anyone have one that they can share?
>= ;
>
> Thanks,
>    Susan

>
>
>

--
Peter Eisentraut              http://www= .2ndQuadrant.com/
PostgreSQL Development, 24x7 Suppor= t, Remote DBA, Training & Services



------=_Part_192752_1073066171.1599130476551--