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 1nES4V-0003Dn-Dh for pgsql-hackers@arkaria.postgresql.org; Mon, 31 Jan 2022 08:29:59 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1nES4U-0004fJ-3p for pgsql-hackers@arkaria.postgresql.org; Mon, 31 Jan 2022 08:29:58 +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 1nES4T-0004f9-PK for pgsql-hackers@lists.postgresql.org; Mon, 31 Jan 2022 08:29:57 +0000 Received: from mail-pj1-x102e.google.com ([2607:f8b0:4864:20::102e]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1nES4R-00033x-GV for pgsql-hackers@postgresql.org; Mon, 31 Jan 2022 08:29:57 +0000 Received: by mail-pj1-x102e.google.com with SMTP id oa14-20020a17090b1bce00b001b61aed4a03so11690956pjb.5 for ; Mon, 31 Jan 2022 00:29:55 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=date:message-id:to:cc:subject:from:in-reply-to:references :user-agent:mime-version:content-transfer-encoding; bh=hF6EGrHGf/67ii6SaM/sQPex8DOZ/GLPY5NUDEEwknI=; b=PQGz5+nL9FvTS7y049vEmog1/iATN+L8hDffVpFP6HfEcyQf1JDSLuCD+eCuIV65AH ZA1DNV+z9Hti7b1cBRr1RrgV4kgnU/33n+9PRSOxeub3cHpmwXnxysbAY1omyCtglg0F lg9aL7mZiXS9KPNptyS+JUQxP4xKLXLN8soiyPkcuehEaGIG44JiQi6jQ57xUv/wPMwe 8mZwqvgdKnXRhQ7KLD9dg8526F2IgFYXPgzbS9oyjRpC0AJexfbTJg+QOuVZm3JM4UVv KPMT0zfj5Ik8MclX9b7olsxdvgPcIHuGdIruDoGDo6rIb4kXD8bzIdqjK5ABBJI/pMG6 xMUA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:message-id:to:cc:subject:from:in-reply-to :references:user-agent:mime-version:content-transfer-encoding; bh=hF6EGrHGf/67ii6SaM/sQPex8DOZ/GLPY5NUDEEwknI=; b=6ANhk5AXhppP7RKR+tu0fG7Tk0CcAPqbft79eGiRZlEsfgoe4n2c2X4GNrQh3SdIRc 3oCyyvjO2R06AZibJTFl+rKgcyaBidcaKh6yWgOjP/ssgHKgzHNYEQ6zS/0KZmjR9K4a +mibaG3p7NqIi3VvvQZOioZ0uu05H8aZx4Jts/JBfN4v//odAoYGx0mUenBQ2DKfKffl NuWLQM0csbfUjf11qaRQjpV2aaQhzTL+gzW0vBQ1UlVq5zvo+eWsFf3OHmrGImRJTfGt uiIeCE0KEmdoaR2mefMI3r7uYFyJ7BSFqQTKFG2BOo0iYCMj/YbE0Dfsw2CnsMvXFzwU d0jQ== X-Gm-Message-State: AOAM530VFxFGBu2rWaFDlqk6w4ydwRkmuz6wy/jibtPJxWipiVc6SwC0 KcCwdsmbqyYhM5b2CK8ueLs= X-Google-Smtp-Source: ABdhPJwjS3AhU/2wVUj7A0Lleot5UG/uC76AupGkqB/+1vf9/2bFvix5n0pBtbaJguGuR5wsvjk2oQ== X-Received: by 2002:a17:902:e5cb:: with SMTP id u11mr19908654plf.52.1643617793103; Mon, 31 Jan 2022 00:29:53 -0800 (PST) Received: from localhost (KD036014041111.ppp-bb.dion.ne.jp. [36.14.41.111]) by smtp.gmail.com with ESMTPSA id rm3sm10581828pjb.13.2022.01.31.00.29.50 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Mon, 31 Jan 2022 00:29:52 -0800 (PST) Date: Mon, 31 Jan 2022 17:29:49 +0900 (JST) Message-Id: <20220131.172949.370093237602326154.horikyota.ntt@gmail.com> To: pchampion@vmware.com Cc: pgsql-hackers@postgresql.org Subject: Re: [PATCH] Accept IP addresses in server certificate SANs From: Kyotaro Horiguchi In-Reply-To: References: <20211217.165430.655740392355518222.horikyota.ntt@gmail.com> User-Agent: Mew version 6.8 on Emacs 26.1 Mime-Version: 1.0 Content-Type: Text/Plain; charset=us-ascii Content-Transfer-Encoding: 7bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk At Thu, 6 Jan 2022 00:02:27 +0000, Jacob Champion wrote in > On Mon, 2022-01-03 at 16:19 +0000, Jacob Champion wrote: > > On Fri, 2021-12-17 at 15:40 +0900, Kyotaro Horiguchi wrote: > > > > > > + inet_net_pton_ipv4(const char *src, u_char *dst) > > > (calls inet_net_pton_ipv4_internal(src, dst, true)) > > > + inet_pton_ipv4(const char *src, u_char *dst) > > > (calls inet_net_pton_ipv4_internal(src, dst, false)) > > > > Sounds good, I will make that change. Thanks for the feedback! > > v3 implements a pg_inet_pton(), but for IPv6 instead of IPv4 as > presented above (since we only need inet_pton() for IPv6 in this case). > It's split into a separate patch (0003) for ease of review. 0001 looks fine as it is in the almost same shape withinet_net_pton about PGSQL_AF_INET and PGSQL_AF_INET6. I'm not sure about the difference on how to handle AF_INET6 between pg_inet_net_pton and ntop but that's not a matter of this patch. However, 0002, +/* + * In a frontend build, we can't include inet.h, but we still need to have + * sensible definitions of these two constants. Note that pg_inet_net_ntop() + * assumes that PGSQL_AF_INET is equal to AF_INET. + */ +#define PGSQL_AF_INET (AF_INET + 0) +#define PGSQL_AF_INET6 (AF_INET + 1) + Now we have the same definition thrice in frontend code. Coulnd't we define them in, say, libpq-fe.h or inet-fe.h (nonexistent) then include it from the three files? +$node->connect_fails( + "$common_connstr host=192.0.2.2", + "host not matching an IPv4 address (Subject Alternative Name 1)", It is not the real IP address of the server. https://datatracker.ietf.org/doc/html/rfc6125 > In some cases, the URI is specified as an IP address rather than a > hostname. In this case, the iPAddress subjectAltName must be > present in the certificate and must exactly match the IP in the URI. When IP address is embedded in URI, it won't be translated to another IP address. Concretely https://192.0.1.5/hoge cannot reach to the host 192.0.1.8. On the other hand, as done in the test, libpq allows that when "host=192.0.1.5 hostaddr=192.0.1.8". I can't understand what we are doing in that case. Don't we need to match the SAN IP address with hostaddr instead of host? regards. -- Kyotaro Horiguchi NTT Open Source Software Center