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 1olAYj-0007XI-I0 for pgsql-admin@arkaria.postgresql.org; Wed, 19 Oct 2022 15:00:41 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1olAYi-0000te-AG for pgsql-admin@arkaria.postgresql.org; Wed, 19 Oct 2022 15:00:40 +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 1olAYh-0000tV-Sx for pgsql-admin@lists.postgresql.org; Wed, 19 Oct 2022 15:00:40 +0000 Received: from mail-wr1-x42e.google.com ([2a00:1450:4864:20::42e]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1olAYd-0007RU-Ix for pgsql-admin@lists.postgresql.org; Wed, 19 Oct 2022 15:00:39 +0000 Received: by mail-wr1-x42e.google.com with SMTP id bp11so29583453wrb.9 for ; Wed, 19 Oct 2022 08:00:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cybertec-at.20210112.gappssmtp.com; s=20210112; h=content-transfer-encoding:mime-version:user-agent:references :in-reply-to:date:to:from:subject:message-id:from:to:cc:subject:date :message-id:reply-to; bh=A+lG8SGJwT27Nh9mpjkwmg9zW5+WfPTppz+D4FWVRCo=; b=2ANT/PJXa3phDYjNi9dGcPxCIMRC29wU/l1WR6cOYh2fpLicUXtGB9ULDGqUBimDre atuOAYwf/OG6TBt4eHIM9R01gJ1OOq5RYxCyNKdpJ6QBeY5O+MkeCxMSmKaP158fiQzF kmU2c5Xhl75WkCVdyTFUzfAoW0KNCdwFaiggrcO3G8T0LUYiaaKgyKeMbl669ecpDQ6X PTGjAiYG4bsxnbCQw8a523jolTDHS2GcOaRMuTURXY+P9DfBDbb4+I+u9NFNCMUZdLnq SYcZ5nloprUntooV40l4pMCvs03ZJLb+c8gsZ6kWmi+r0jfyk+GkrZydhRGW63acCdNS Y+lQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:user-agent:references :in-reply-to:date:to:from:subject:message-id:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=A+lG8SGJwT27Nh9mpjkwmg9zW5+WfPTppz+D4FWVRCo=; b=h5XB91CxCi9NVn4sGS34oJnUDr3jhv0jK5vJjkQTzbGKuLRA7rn32JcEV+/qMbfz/j El9npJcrtL2Wqwf8oviCJ9tXnfIG2SEp+UwyO/kqopA0qv8O9OTJTgBFmS/V/6XdL/3w Ha7gkdbP/HMCrFuFUFjyvFt728LpUhuudHcDtSa5IPpWXlUsNC6rjueUfoLCe1H60Lo8 88XWVGuPF/OswnCszDPtnRqi9i9mTbbgOeyrAwrohYcYWUIbIUGDghNV+4ZaCv0C6uQg SJvyFew29RZby+5vLxPPknkVtgB2GMi1/+Ph3dT49cyuEdGFvNNyRavxDTRJ08Y7NWWs GLtQ== X-Gm-Message-State: ACrzQf2xihCCnegQbY6wFg38RBJOQxMPgyZEi1Wbjb1DZUQlwXt9JNpl XjMvU8Lwr3bRVBUX1H4NEKxbPiWmHIj1SQ== X-Google-Smtp-Source: AMsMyM7xlWdt0O7M6NLLHMogaaVq3YICLwv/puJVENs0crdpzbrotbwfnmn+HFI8eghTf87868O6zg== X-Received: by 2002:adf:ea42:0:b0:22e:3ca8:c269 with SMTP id j2-20020adfea42000000b0022e3ca8c269mr5398345wrn.186.1666191634140; Wed, 19 Oct 2022 08:00:34 -0700 (PDT) Received: from localhost.localdomain ([2001:871:5e:6bcf:6bc6:867b:e3cb:a53e]) by smtp.gmail.com with ESMTPSA id j8-20020a05600c1c0800b003c6b7f5567csm2799617wms.0.2022.10.19.08.00.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 19 Oct 2022 08:00:33 -0700 (PDT) Message-ID: <14560889a3fece7211c94c12b74b524aa5ca86f2.camel@cybertec.at> Subject: Re: proper pg_hba config to require ssl from non-local/private ips From: Laurenz Albe To: Matthew Lenz , pgsql-admin@lists.postgresql.org Date: Wed, 19 Oct 2022 17:00:32 +0200 In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" User-Agent: Evolution 3.42.4 (3.42.4-2.fc35) MIME-Version: 1.0 Content-Transfer-Encoding: 8bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Wed, 2022-10-19 at 07:49 -0500, Matthew Lenz wrote: > This is what I've got currently but it's still allowing non-ssl connections from remote (non-local/private) hosts. Any thoughts? > > local   all             all                                     trust > host    all             all             127.0.0.1/32            trust > host    all             all             ::1/128                 trust > host    all             all             10.0.0.0/8              md5 > host    all             all             172.16.0.0/12           md5 > hostssl all             all             all                     md5 clientcert=verify-ca > > Also when I require SSL on the client it allows SSL connections without a CA signed cert > which I thought clientcert=verify-ca in this pg_hba should require. Then your client IP address must match the CIDR 172.16.0.0/12, right? That line matches both unencrypted and encrypted connections, that's why it is used for SSL connectios as well. To change that, use "hostnossl" in the penultimate line. Yours, Laurenz Albe -- Cybertec | https://www.cybertec-postgresql.com