all lists on lists.proxmox.com
 help / color / mirror / Atom feed
From: Lucas Barros <lucasbarros.kam@gmail.com>
To: pve-devel@lists.proxmox.com
Cc: t.lamprecht@proxmox.com, Lucas Barros <lucasbarros.kam@gmail.com>
Subject: [PATCH cluster v2 1/3] setup: node certificate: only use the first search domain for the FQDN
Date: Sun, 15 Nov 2026 22:00:11 -0300	[thread overview]
Message-ID: <20261116010014.88737-2-lucasbarros.kam@gmail.com> (raw)
In-Reply-To: <20261116010014.88737-1-lucasbarros.kam@gmail.com>

The certificate of a node gets the node name plus the search domain of
/etc/resolv.conf as subject CN and as DNS subject alternative name. The
search line can list multiple domains, and once the resolv.conf parser
in pve-common returns all of them, appending the whole list results in
a certificate with 'CN=node.a.example b.example' and a SAN with the
same, invalid, DNS name.

Use only the first domain. That is what the certificate got so far, as
the parser only returned the first domain, and it is the domain the
installer writes, so for the common setups it is the domain the node
lives in.

Signed-off-by: Lucas Barros <lucasbarros.kam@gmail.com>
---

changes since v1:
* new patch: with 3/3 applied alone, the certificate got
  'CN=node.a.example b.example c.example' and the same invalid name as
  DNS SAN, as Thomas pointed out

Using the first domain keeps today's certificates, as the parser only
returned that one so far. I also looked at the canonical name from
getaddrinfo() (PVE::Tools::get_fqdn()), but that can change the CN on
nodes where /etc/hosts or DNS do not match resolv.conf, so I kept the
current source. This has to be applied before 3/3, or pve-common needs
a Breaks on older pve-cluster.

Tested with 'pvecm updatecerts --force' on a PVE 9 node with three
search domains, see the cover letter.

This patch was prepared with the help of an LLM based coding assistant; I
reviewed the change and ran the tests mentioned above myself.

 src/PVE/Cluster/Setup.pm | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/src/PVE/Cluster/Setup.pm b/src/PVE/Cluster/Setup.pm
index 8a398d3..f6cc689 100644
--- a/src/PVE/Cluster/Setup.pm
+++ b/src/PVE/Cluster/Setup.pm
@@ -640,8 +640,9 @@ sub gen_pve_ssl_cert {
     my $fqdn = $nodename;
 
     my $rc = PVE::INotify::read_file('resolvconf');
-    if ($rc && $rc->{search}) {
-        $fqdn .= ".$rc->{search}";
+    # the search list can hold more than one domain, only the first one is used for the FQDN
+    if ($rc && (my ($domain) = split(' ', $rc->{search} // ''))) {
+        $fqdn .= ".$domain";
         $names .= ",DNS:$fqdn";
     }
 
-- 
2.50.1 (Apple Git-155)




  reply	other threads:[~2026-11-16  1:00 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-07 22:30 [PATCH common] fix #6357: inotify: resolv.conf: parse all search domains Lucas Barros
2026-11-11 23:15 ` Thomas Lamprecht
2026-11-16  1:00   ` [PATCH cluster/qemu-server/common v2 0/3] fix #6357: parse all search domains of resolv.conf Lucas Barros
2026-11-16  1:00     ` Lucas Barros [this message]
2026-11-16  1:00     ` [PATCH qemu-server v2 2/3] cloudinit: only use the first search domain for the FQDN Lucas Barros
2026-11-16  1:00     ` [PATCH common v2 3/3] fix #6357: inotify: resolv.conf: parse all search domains Lucas Barros
2026-11-16  1:48     ` [PATCH cluster/qemu-server/common v2 0/3] fix #6357: parse all search domains of resolv.conf Thomas Lamprecht
2026-11-16 13:32     ` superseded: " Lucas Barros

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20261116010014.88737-2-lucasbarros.kam@gmail.com \
    --to=lucasbarros.kam@gmail.com \
    --cc=pve-devel@lists.proxmox.com \
    --cc=t.lamprecht@proxmox.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal