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 1kDozs-0002oC-Hs for pgsql-general@arkaria.postgresql.org; Thu, 03 Sep 2020 13:09: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 1kDozr-0002Yj-Ht for pgsql-general@arkaria.postgresql.org; Thu, 03 Sep 2020 13:09:47 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kDozq-0002Yc-On for pgsql-general@lists.postgresql.org; Thu, 03 Sep 2020 13:09:47 +0000 Received: from sonic305-21.consmr.mail.ne1.yahoo.com ([66.163.185.147]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1kDozn-0007m3-QG for pgsql-general@postgresql.org; Thu, 03 Sep 2020 13:09:45 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=verizon.net; s=a2048; t=1599138581; bh=DRQtnRvUfmYQT+v4qz3c7/C52hrcSIJYGSNxGav7XCc=; h=Date:From:Reply-To:To:Cc:In-Reply-To:References:Subject:From:Subject; b=DHcD5DCWL22GFHRkOy7XXspF5WHbjs77a8K1LJKyaQI7sEvYzgcJmi7/MRWzMKsarP/EAPG2zPJDaTFGVziLZHA7rUgJEhDLcNJx8ygk6r14Jq1z4t5pvTn4twRzw8050d4l55CbqVLoWqgEGV2BSqHS19GlJoipALhkdEZbxTVyYyBr7YqAwl+/s9V8wKKWy9XZH5CIsWqFQQsG9jDOZbOLNUIpZ6DKEZ/5yYOGXLyTi0VRt4MUb5w8M081mbIbaKnY6KDfG9GQ/miFyjbqJPOxEBeYLFgkoe6uHKBQUaxWkIT6Ur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.iCdiMqgMGNxd08maAGEZAJSZaC98C.7Lq.rh ZD68W6T1NQ6cbeyJj3MDgupMBjM3Ee5pKjLtwtst_LxioMVfrQxESHLr8wxRNdfwmTF1KFO9n_mE rFkpFrwp6y_5ZYA2x0MVJ4YY0ScLwV.O9t8Zy11aLgfW3XipIzZHTqUqyEjYT7ppTceRpiQ9kPpD 1jgBLVnAhbqDf61mbhORVNwcWQEDvq12EhlDrGVTc1GST5Rmiq0CQOHaAEkJpspZoKZEqTjD6mmE _tgHo6LaL2Qey6cpS0S4MERlnnxT5b5oyFJAoWc8sN_QzdLvI9lVYcoTEKzdq5bSsiwXcMn4DnK5 2c5ViEOQsd45n1jeUpmqu5jLILvXFdbQay2CNolu3qVLe5thz94XmkZVaXTjpTNFIhZ0R.kq6wXx pg8p1eRT2mUm_5F2__JuhhckvCpn7oEY.cgKceFcQF8Y.YoWIN_QeIFVqIWwFn0CUfrG8t7d_YNt 0kwUezCje2gOByIKVOWpM5ngvdvWE Received: from sonic.gate.mail.ne1.yahoo.com by sonic305.consmr.mail.ne1.yahoo.com with HTTP; Thu, 3 Sep 2020 13:09:41 +0000 Date: Thu, 3 Sep 2020 13:09:39 +0000 (UTC) From: Susan Joseph Reply-To: Susan Joseph To: "sfrost@snowman.net" Cc: "pgsql-general@postgresql.org" Message-ID: <1030654552.2676681.1599138579381@mail.yahoo.com> In-Reply-To: <1878379566.2669355.1599137708587@mail.yahoo.com> References: <976526972.6642745.1598278223530.ref@mail.yahoo.com> <976526972.6642745.1598278223530@mail.yahoo.com> <20200903122856.GL29590@tamriel.snowman.net> <1878379566.2669355.1599137708587@mail.yahoo.com> Subject: Re: SSL between Primary and Seconday PostgreSQL DBs MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_Part_2676680_1275699370.1599138579377" 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: 17593 List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk ------=_Part_2676680_1275699370.1599138579377 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable So I made the changes on the secondary to change the sslmode to verify-full= I removed the clientcert=3D1 in pg_hba.conf and removed any connections oth= er than sslI removed the passfile info from recovery.confand now I am getti= ng this error: 2020-09-03 13:01:49.990 UTC [7963] FATAL:=C2=A0 could not connect to the pr= imary server: server certificate for "lc-subca-pg.theforest.sap" does not m= atch host name "192.168.1.142" My certificate for my primary is: Version: 3 Serial: 0x1B Issuer:=C2=A0 CN=3DLifeCycle SubCA, OU=3DCA, OU=3DDoDSAP, OU=3DDoD, O=3DU.S= . Government, C=3DUS Subject: CN=3Dlc-subca-pg.theforest.sap, OU=3DNPE, OU=3DDoDSAP, OU=3DDoD, O= =3DU.S. Government, C=3DUS NotBefore: 20 AUG 2020 16:46:48 GMT NotAfter: 05 AUG 2028 18:51:19 GMT KeyType: RSA2048 Signature Algorithm: sha384RSA Extensions:=20 Enhanced Key Usage =C2=A0=C2=A0=C2=A0 Server Authentication =C2=A0=C2=A0=C2=A0=20 =C2=A0=C2=A0=C2=A0 Client Authentication Key Usage (Critical) =C2=A0=C2=A0=C2=A0 Digital signature =C2=A0=C2=A0=C2=A0 Key encipherment =C2=A0=C2=A0=C2=A0 (A0) Subject Alternative Name =C2=A0=C2=A0=C2=A0 DNS name:=C2=A0=C2=A0=C2=A0 lc-subca-pg.theforest.sap =C2=A0=C2=A0=C2=A0 IP Address:=C2=A0 192.168.1.142 Subject Key Identifier =C2=A0=C2=A0=C2=A0 FF4C0DCD62B17F99935DB3977D49711892958E20 Authority Key Identifier =C2=A0=C2=A0=C2=A0 Key ID: 6495303FEB8925B9C83B7A63FF7F026C974E308E SHA-1 Fingerprint: 51B1A879EB5ADAFA23042A8E84165CF89438F29B =20 =20 Susan Joseph sandajoseph@verizon.net =20 =20 -----Original Message----- From: Susan Joseph To: sfrost@snowman.net Cc: pgsql-general@postgresql.org Sent: Thu, Sep 3, 2020 8:55 am Subject: Re: SSL between Primary and Seconday PostgreSQL DBs 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_2676680_1275699370.1599138579377 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable
So I made the changes on the secondary to change the = sslmode to verify-full
I removed the clientcert=3D1 in pg_hba.conf and remov= ed any connections other than ssl
I removed the passfile info from recovery.conf=
and now I am getting this error:

2020-09-03 13:01:49.990 UTC [7963] FATAL:  could= not connect to the primary server: server certificate for "lc-subca-pg.the= forest.sap" does not match host name "192.168.1.142"

My certificate for my primary is:

Version: 3
Serial: 0x1B
Issuer:  CN=3DLifeCycle SubCA, OU=3DCA, OU=3DDoDSAP, OU=3DDoD, O=3DU.S= . Government, C=3DUS
Subject: CN=3Dlc-subca-pg.theforest.sap, OU=3DNPE, OU=3DDoDSAP, OU=3DDoD, O= =3DU.S. Government, C=3DUS
NotBefore: 20 AUG 2020 16:46:48 GMT
NotAfter: 05 AUG 2028 18:51:19 GMT
KeyType: RSA2048
Signature Algorithm: sha384RSA
Extensions:
Enhanced Key Usage
    Server Authentication
   
    Client Authentication
Key Usage
(Critical)
    Digital signature
    Key encipherment
    (A0)
Subject Alternative Name
    DNS name:    lc-subca-pg.theforest.sap     IP Address:  192.168.1.142
Subject Key Identifier
    FF4C0DCD62B17F99935DB3977D49711892958E20
Authority Key Identifier
    Key ID: 6495303FEB8925B9C83B7A63FF7F026C974E308E
SHA-1 Fingerprint: 51B1A879EB5ADAFA23042A8E84165CF89438F29B


Susan Joseph
sandajoseph@verizon.net


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

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:
>    - primary_conninfo =3D 'us= er=3Drep_user passfile=3D''/data/.pgpass'' host=3D<Primary DB IP> por= t=3D5432 sslmode=3Dverify-ca sslcert=3Dclient.crt sslkey=3Dclient.key sslco= mpression=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 accepte= d.

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_u= ser line to:
>   
>&nb= sp;   - hostssl          = replication         rep_user &= nbsp;         <primary IP>/32=       cert clientcert=3D1

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

> My questions are:  =
>    - Do I need to set the information in= the Secondary postgresql.conf?  Originally I did not set this and eve= rything worked but I saw errors in my log files that said to do SSL these n= eeded 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? 

The only connection you're talking about he= re 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.
Ho= wever, 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?  Is that how you get SSL "turned = on" for communications between the primary and the rep_user account?

'hostssl' will only match an incoming connec= tion if it's being made over
SSL.  As long as you do= n'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<= br clear=3D"none">getting used instead.

>    - If I leave my key file encrypted then every time my d= atabases have to be started have to enter the password.  So you can ei= ther 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 ti= me the database is started up.  As someone in the security field I hav= e a tough time leaving the key unencrypted but as some setting up a product= ion system that is located on a network that you can't get to without direc= tly accessing the server I feel that is enough security that I can leave th= em unencrypted.  Thoughts?

You co= uld use a vaulting system to pull the key and make it available at
startup and then remove it after, perhaps, but I would suggest th= at it's
pretty common to have SSL keys unencrypted on sys= tems which are doing
SSL and otherwise secured.

>    - Am I missing anything?&nbs= p; There are no videos out there that show how to stand up a 2 way SSL comm= unication channel between the primary and secondary, or does anyone have on= e 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 reass= urance
you're looking for.  Things like the differen= ce between verify-ca and
verify-full aren't really very w= ell 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_2676680_1275699370.1599138579377--