Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eNKNw-0002Kz-Ib for pgsql-general@arkaria.postgresql.org; Fri, 08 Dec 2017 15:16:20 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eNKNu-0004tw-P4 for pgsql-general@arkaria.postgresql.org; Fri, 08 Dec 2017 15:16:18 +0000 Received: from makus.postgresql.org ([2001:4800:1501:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1eNKNu-0004tn-Eq for pgsql-general@lists.postgresql.org; Fri, 08 Dec 2017 15:16:18 +0000 Received: from tamriel.snowman.net ([96.255.250.162]) by makus.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1eNKNs-0004L9-2T for pgsql-general@lists.postgresql.org; Fri, 08 Dec 2017 15:16:17 +0000 Received: by tamriel.snowman.net (Postfix, from userid 1000) id 718D75F795; Fri, 8 Dec 2017 10:16:15 -0500 (EST) Date: Fri, 8 Dec 2017 10:16:15 -0500 From: Stephen Frost To: chiru r , Adam Tauno Williams Cc: Forums postgresql , pgsql-general@lists.postgresql.org Subject: Re: Secured ldap connectivity between PostgreSQL and LDAPs server Message-ID: <20171208151615.GT4628@tamriel.snowman.net> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="1NZHqhlop58Ta3Ju" Content-Disposition: inline In-Reply-To: <1512741385.4225.6.camel@whitemice.org> User-Agent: Mutt/1.5.21 (2010-09-15) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk --1NZHqhlop58Ta3Ju Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Greetings Chiru, Adam, * chiru r (chirupg@gmail.com) wrote: > We are using LDAP authentication for authenticating users in PostgreSQL on > Linux server and we are able to authenticate successfully. What LDAP server are you connecting to for authentication..? If you're using Active Directory then you really should be using Kerberos/GSSAPI, not LDAP (or LDAPS). With LDAP-based authentication, the user's password is sent in cleartext (or tunneled cleartext if you're using SSL) and then used by the server to try to validate the user in LDAP. That's much worse from a security perspective than using Kerberos/GSSAPI and in an AD environment, Kerberos is already set up and available. > However we want to configure secured LDAP (LDAPS) by using Certificates. Are you looking to have client-side certificates, or do you just want to validate the LDAP server's certificate? > Please help me i have couple of questions to configuring LDAPS. >=20 > 1. Which location we need to keep the LDAPs Certificate files in PostgreS= QL > Linux server ?. On Linux, PostgreSQL will be using ldap_start_tls_s() if you have ldaptls=3D1 and then it's up to the LDAP library you've built your PostgreSQL server against how to deal with anything further. Most likely this is OpenLDAP and it'll be built against OpenSSL or GNUTLS and you'll have some system-wide certificate store which you can place the CA's certificate into (eg: /etc/ssl). > 2. Do we need to change any configuration file for certificate references > on Linux server ? . Not likely. If you do, though, it'd be in either the configuration for OpenLDAP or for the SSL library it's built against (as installed on your system). > 2. What need to be changed in Postgresql.conf file and pg_hba.conf file ? ldaptls=3D1 is the main thing to get PG to use ldap_start_tls_s(). * Adam Tauno Williams (awilliam@whitemice.org) wrote: > On Fri, 2017-12-08 at 07:40 -0500, chiru r wrote: > > We are using LDAP authentication for authenticating users in > > PostgreSQL on Linux server and we are able to authenticate > > successfully.=A0 >=20 > Then one presumes you are using PAM (?) for password authentication - > this question is really about pam_ldap, it is not specific to > PostgreSQL in any way. =A0 I'm not sure why you're thinking this involves PAM at all, PostgreSQL supports the ability to authenticate users against an LDAP directory directly. Not that it's a good idea, because it isn't, as discussed above. pam_ldap *could* be used, but definitely my assumption going in here is that the pg_hba.conf has been configured to use the 'ldap' auth method, not the 'pam' auth method. Hopefully that's the case, or most of what I've gone through here isn't accurate and we'd have to get into talking about PAM. ;) > > Please help me i have couple of =A0questions to configuring LDAPS.=A0 > > 1. Which location we need to keep the LDAPs Certificate files in > > PostgreSQL Linux server ?. > > 2. Do we need to change any configuration file for certificate > >=A0references on Linux server ? . >=20 > The server should be configured to recognize certificates signed by > whatever authority you are using - where they go to do that depends on > your distribution. =A0Usually that involves putting the signing > certificate somewhere like=A0/usr/share/pki/ca-trust-source/anchors/ and > running "update-ca-trust". =A0If your server already recognizes your CA > you don't need to do anything other than changing PAM to use LDAPS. Right, though this will depend on the specific Linux distribution, of course. > > 2. What need to be changed in Postgresql.conf file and pg_hba.conf > > file ?=A0 >=20 > Nothing, PostgreSQL just calls the PAM library. =A0It does not care what > happens beneath that. PostgreSQL calls into the OpenLDAP library, as discussed above, at least when the 'ldap' auth method is being used. Thanks! Stephen --1NZHqhlop58Ta3Ju Content-Type: application/pgp-signature; name="signature.asc" Content-Description: Digital signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v1 iQIcBAEBCgAGBQJaKqy/AAoJEO1sijiDR2RVpkMP/ic3cBQXHQEr7gJRMr4IhAZF YY68doOenVppMy63qOdjv+BFJGE6xXqMyN5lAY4sQgBkV30ZPZUvfhi0FMI9PTFo LKl6FoaZT7npwDumUbrE3EXlALYE++C/A+Day1DtvCw6S8X4ldVIviFoqUav/rUa QpMBdhfmTvT29yS9C0E2aggl72DcEBHwWrrZcT9zK7ZK1zX/osxUiA9uaOXB8KlN LBHTdCbSF0WMNtOx9srFp+Al6Azo36e5XJuz+ripfAO9P5QQG0NNXJokHbAu2OsD ZePxe5mew3zvU/Kbl+cxd2lWwJkJyfqHrnIf/3LfwAX5HHqYq0B7zwilpNbIEsjy 5DbWjj5PKpC+cxZ/daelIBNrDkdgo4KDRlCqrE5IkcSeB/LlPAL5+JpUCa6JcGDF XkhsIvVuc4APsiHW2rM+F+E6fAvwyK/pDPpD7XNFOaeUMQNt4e0BsBfBdDVDbAih UmG4RHpqpWGUMCTP2goMDCloQi7snqUMBdEwRTpaJOyjLBywOtSZ2kOo2zPL3OpV jc7R9S66rnWlmw7HY3vuNsik4OzVbCTrtKwLQtjP7lzF7rGPUz4LnhimK9o1HtaP HIINpfT1yxutd1kX2Y3t7XttcQTi+kXfAB3rWDv6ZGVNfF5oPQhv9x9LozqdaHgO fl6tuwuwyHF3tS1mi2qS =MCPO -----END PGP SIGNATURE----- --1NZHqhlop58Ta3Ju--