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 1l31ts-0005pc-FH for pgsql-general@arkaria.postgresql.org; Fri, 22 Jan 2021 19:15:16 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1l31tq-0001DO-B5 for pgsql-general@arkaria.postgresql.org; Fri, 22 Jan 2021 19:15:14 +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 1l31to-0001DE-GN for pgsql-general@lists.postgresql.org; Fri, 22 Jan 2021 19:15:13 +0000 Received: from wout3-smtp.messagingengine.com ([64.147.123.19]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1l31tl-0005kH-ID for pgsql-general@lists.postgresql.org; Fri, 22 Jan 2021 19:15:11 +0000 Received: from compute3.internal (compute3.nyi.internal [10.202.2.43]) by mailout.west.internal (Postfix) with ESMTP id E79D418AA; Fri, 22 Jan 2021 14:15:05 -0500 (EST) Received: from mailfrontend1 ([10.202.2.162]) by compute3.internal (MEProxy); Fri, 22 Jan 2021 14:15:06 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=aklaver.com; h= subject:to:references:from:message-id:date:mime-version :in-reply-to:content-type:content-transfer-encoding; s=fm2; bh=d t6P5dRTHuDeiuYIptzRhafRe/TU895mHFZrcXkwrcs=; b=qhEJcoWY0skvIKYJx aFCd4cSCOzKaalrr2ygOSZFItzJznJRJ8aiYiUXnWObJqAkF1Y4WJbC6awSQOfP8 PU0lGV+/iUClX4p9Gs1x5gG7ui7ecU+V4dBGXViNh+PUsF8RN9tBmecuGnG4CI8s CkJl/iiWSuCOq2mb6NYF5hN/YfwuM00d1c2ow9hap1IO15QvbcCfqdtSojRJLmLq 0mWQigLCq/9ivh+2lQacx+oGc8wGakrMiLFb8V6YGMdgpOg5BfmnkWNlxHD7pk5p TEy3cLBQe6Xrc1KAC5O7dihnNcg9Nz0XbEvUfJIOspgUN5aZGflyQ0dWm0mjVX+S U/opw== 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=fm1; bh=dt6P5dRTHuDeiuYIptzRhafRe/TU895mHFZrcXkwr cs=; b=HwyYyL4KtrwPcgtz+fMDI8o7hgsBMfVs5N1Qb0xksS512haN5hN9o2PBd N6TKe/PEElM7DKsJaFNHcnrS3/onUyBzBtZZfYM6QITUj7ySxcd8BeucsAwpKrfY PuHCk0Cq3bKP8DLZbq4jJylJld/pLx2MXzmeuO8mfAmLzaaTUbRbo22St56wiUSP plftFshz2uROlJXxFkAIkIzBpV4XW658aMrDkustDTD2gNvJJcAYlNkz1tt6EKC+ mAp+w20tbq51UTtYgo9UvcYoNFFutvknUS0VDdaQJtBO+YVIQZhV9opS2QlhKkns BZKerOfigqbdKVY3YdSUESIaMgDNw== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduledrudeigdduvdekucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhepuffvfhfhkffffgggjggtgfesthekredttdefjeenucfhrhhomheptegurhhi rghnucfmlhgrvhgvrhcuoegrughrihgrnhdrkhhlrghvvghrsegrkhhlrghvvghrrdgtoh hmqeenucggtffrrghtthgvrhhnpeduudefjeetveffhefgudehtdfhvdetkeeiueehfeev veduteekleeuheegudehhfenucffohhmrghinhepphhoshhtghhrvghsqhhlrdhorhhgne cukfhppeejhedrudejvddrudegrddujeenucevlhhushhtvghrufhiiigvpedtnecurfgr rhgrmhepmhgrihhlfhhrohhmpegrughrihgrnhdrkhhlrghvvghrsegrkhhlrghvvghrrd gtohhm X-ME-Proxy: Received: from [192.168.1.4] (75-172-14-17.tukw.qwest.net [75.172.14.17]) by mail.messagingengine.com (Postfix) with ESMTPA id A4F9D240069; Fri, 22 Jan 2021 14:15:04 -0500 (EST) Subject: Re: localhost ssl To: Rob Sargent , "pgsql-generallists.postgresql.org" References: From: Adrian Klaver Message-ID: <1ca17e3b-14de-69ff-5f0b-4082376571ca@aklaver.com> Date: Fri, 22 Jan 2021 11:15:03 -0800 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.6.1 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 8bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On 1/22/21 11:04 AM, Rob Sargent wrote: > > I will need to enforce ssl/tls in my production environment so I thought > I would try setting things up on localhost to see how that went. > > Then I noticed that my successful connections from > "/usr/lib/postgresql/12/bin/psql -U postgres -h localhost -P pager=off > postgres" report: > >   psql (12.5 (Ubuntu 12.5-0ubuntu0.20.04.1)) >   SSL connection (protocol: TLSv1.3, cipher: TLS_AES_256_GCM_SHA384, > bits: 256, compression: off) >   Type "help" for help. > > though my pg_hba.conf does not specify SSL at all Yes it does(implied): https://www.postgresql.org/docs/12/auth-pg-hba-conf.html "host This record matches connection attempts made using TCP/IP. host records match SSL or non-SSL connection attempts as well as GSSAPI encrypted or non-GSSAPI encrypted connection attempts." Also I'm guessing you have ssl = on in postgresql.conf and server cert setup. If you want to enforce SSL then: " hostssl This record matches connection attempts made using TCP/IP, but only when the connection is made with SSL encryption. To make use of this option the server must be built with SSL support. Furthermore, SSL must be enabled by setting the ssl configuration parameter (see Section 18.9 for more information). Otherwise, the hostssl record is ignored except for logging a warning that it cannot match any connections. " Read below for more information: https://www.postgresql.org/docs/12/ssl-tcp.html > >   # Database administrative login by Unix domain socket > >   local   all             postgres                                peer > > >   # TYPE  DATABASE        USER            ADDRESS METHOD > >   # "local" is for Unix domain socket connections only > >   local   all             all                                     peer > >   # IPv4 local connections: > >   host    all             all             127.0.0.1/32            md5 > >   host    all             all             127.0.1.1/32            md5 > >   # IPv6 local connections: > >   host    all             all             ::1/128                 md5 > > > So to the questions: > 1. Am I already getting encrypted connections and if so, how? > 2. In production I hope to name the role with each connection as I want > the search_path set by the connecting role.  Will I need a cert per role > with CN=? > > -- Adrian Klaver adrian.klaver@aklaver.com