Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1wDLmq-002sSu-1w for pgpool-hackers@arkaria.postgresql.org; Thu, 16 Apr 2026 12:25:37 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1wDLmp-005Wad-1o for pgpool-hackers@arkaria.postgresql.org; Thu, 16 Apr 2026 12:25:35 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1wDLmp-005WaV-0t for pgpool-hackers@lists.postgresql.org; Thu, 16 Apr 2026 12:25:35 +0000 Received: from mail-ej1-x634.google.com ([2a00:1450:4864:20::634]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.98.2) (envelope-from ) id 1wDLmm-00000001Oy1-3cjx for pgpool-hackers@lists.postgresql.org; Thu, 16 Apr 2026 12:25:35 +0000 Received: by mail-ej1-x634.google.com with SMTP id a640c23a62f3a-b9c1da7ac63so1284872666b.0 for ; Thu, 16 Apr 2026 05:25:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1776342331; cv=none; d=google.com; s=arc-20240605; b=aa3B3nCZK5DtMCsza0EXSjAWjHMcZWtWqcI/Sw/hCvkeHUkkMzIBU9ezV+GrwaRTsN u9dY+vTLbEWCZrAvTC8cUE0xp7L8TKq2foqxXvB8AfvomsM908MeG8gjVdBlWp3GJTz5 QLaWfp84b2C9LF/v2oJaEiwsSwq9g2cCRQqcAN3wXPAnlid24Op6fHJ5B/gOwCovUtWm Y64bYWZBKXSxhHHeT0coZL7fgIYp7JQCGK6TLdkPo0rQuElMuUUzEvbGJS5jevAEzxvC qhKimV0R6ShNGMORiqh64Bn4p2/j0FQYV+i1BpN6MAkhnq229G5difLnv9ZW+r3C8cRb jTsA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:dkim-signature; bh=Ylru7X9PGyUmE8IyPxcjkH9HLU69XCQfyzuunQl3b6A=; fh=m3oiE62fRN5J1XaE+5vpHZRIgCyFefxVI0mFw3d8yxA=; b=JNop4rF2rnoUyDoe6ljAoQ9aq0j4XKgkmVdIF9W9B2+CFlC+OJhVs1XbRR8OwhO2cp bjZ2kW6qKs8TAk8PMvHGY1oGqa4UHZeCMM2WnGpRuKQ7/XkdFNCyakKrlBx205gqcc+T 4PYsb4BtFg55SAp+TzEytoupemMMhNQYTkO3klqxFrVcozD9uutyee9GrupugbEfJlWX ww5Z7jexCOuQigy2LiqgeHt0KYY5/iGhNdVE/t7aRXzlXK7iPLuPgP00zRvqyz/ZsSry Xswz+rCLcQnlJ6VUhGr9rpraFzejD8pUdT0f85S0Ymk9gUGEokH5+QsYMD0ceXXetNOu QPHA==; darn=lists.postgresql.org ARC-Authentication-Results: i=1; mx.google.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1776342331; x=1776947131; darn=lists.postgresql.org; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=Ylru7X9PGyUmE8IyPxcjkH9HLU69XCQfyzuunQl3b6A=; b=L3alHw1JbxdNKGTm+QUpbGVnsemUMxDecxD1gWpcRX2TyI973XBzZ8AtBXXpe7oduX jdyfRtVm4w7dd/i9h0HFHa88rHp/DwF7+1XsVm4l52xi8KFqJSTtGGj2t9+zAsMYw5tf dj9cStE7EkGjWFZCgoIX8bUsZfg6ItjaEtoHYXf0OqEnmo27DzNx1UqkTeGqTCtUSoUg pLsz1zdxEXG7T55T6DTIQG+pz5+43QHEPmnk4FePcUa5wT5Tenoa4edxZ000/NT63nul CzfZYHSOfBSzeemejomYXkiF28XjMS6M99E/XpNxUYIDtIadVVqJ62DlxL9bEmA+d80I 7b4w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1776342331; x=1776947131; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=Ylru7X9PGyUmE8IyPxcjkH9HLU69XCQfyzuunQl3b6A=; b=dlcSUxloFNq2AmnPC3B41c6ROcdea7+T27U3Mu+FEE2DOC5iFgENKhuwe7dY+DbGTK /bIftNhfXEu3QAyRxFDZX3HBzAsgtmusgeBk0qB8I0shNnpRUQEpffy/jtP9DPMjClwa Ka9y87iqEueid6wHocJv8tuNlAsC/tNMMJpSlqQSlbK1KzHAl45UBrSpHaMNYabl7AFU qELzaxqNCCnsIWZfBFH/09CoTR9mkbrig1ybrCPxkQYfOOL1r+Gm1RRc+uEMMmuTt5d3 mFp3yrLn5wYrRO/4JrD6LVu16k4+fz262AuDQht7RnRyC3CkRGHvnSIv+vHmfbESwmfG A8Sw== X-Gm-Message-State: AOJu0YxD7ZW3eHh2+UcqYLQNGKnV8g0j98DOCrlobRAxS2EMpVLZSlQw PY2OYVlFMdvfd1wNdOZ8VmkMc8WcvbD4dYgzSxCUrhoPueDicbQ61nkLKebtSTLr8PTzcxljQst fKUJB0m6Xf5Ho2ClCX0+GIzbzOMLcs2c= X-Gm-Gg: AeBDietux12JlDRxbdqlmeiBQHDUJbVKemzGABvc8nOeihi5ETdoVrC3vupwmehX+VB wpU0sH00SsYPqWrqImU+UmIizXRlgzOFkxQKAGJAtTQ+Eg5k8FEjrbMG9vdbD2d8hz9kjPz3CKx TIQwFT3iPblnjsLeXD9BDP/qmnZTDHazwQCZxNiISwUK4m+H4baVd/oaLGZDxoIC9uBYaq6Jj5D IZstznbgXE19955KnGcM4zyuNjeEgXjJbdnrew8Fick+ZwR7ZMbTErzWcsA/5w2JwQUZyrVJ0We cDlGe82vgk2TyDV/YKn3Gm78i18= X-Received: by 2002:a17:907:e115:b0:b9c:6ef1:ed13 with SMTP id a640c23a62f3a-b9d727aa28fmr986681666b.31.1776342330794; Thu, 16 Apr 2026 05:25:30 -0700 (PDT) MIME-Version: 1.0 References: <20260414.170151.1083817546153854089.ishii@postgresql.org> <20260416.193138.2156629846536617464.ishii@postgresql.org> In-Reply-To: <20260416.193138.2156629846536617464.ishii@postgresql.org> From: Bob Ross Date: Thu, 16 Apr 2026 14:25:17 +0200 X-Gm-Features: AQROBzAKBdt6KF1iKn-_YGTxyg8oiQPn_H7MPHanI-w34tDzCk983d-FR66ksag Message-ID: Subject: Re: Rotate SSL certificates on reload (SIGHUP) without restart To: Tatsuo Ishii Cc: pgpool-hackers@lists.postgresql.org Content-Type: multipart/mixed; boundary="000000000000a0a5bc064f92ed67" List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --000000000000a0a5bc064f92ed67 Content-Type: multipart/alternative; boundary="000000000000a0a5ba064f92ed65" --000000000000a0a5ba064f92ed65 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Hi Tatsuo, Thank you for the report and the log, that was very helpful. The bug was in the test, not in the core patch. Test 4 in 042.ssl_reload set PGSSLROOTCERT=3D"$CADIR/ca1.crt" on both psql invocations. The intent w= as to use ca1.crt for server-side client-certificate verification, but PGSSLROOTCERT actually controls client-side server certificate verification, and ca1.crt is a freshly generated CA that never signed pgpool's server.crt. Because libpq upgrades sslmode=3Drequire to verify-ca behavior when a root CA file is provided, psql immediately sent unknown_ca back to pgpool and aborted the handshake before server-side client-cert verification ever ran. Fix: both lines now use PGSSLROOTCERT=3D"etc/$SSL_CRT". Since server.crt is self-signed it acts as its own root, so psql accepts pgpool's server cert, the handshake completes, and the test exercises what it was always meant to test: whether pgpool enforces the new ssl_ca_cert after reload. No changes to the core patch. Please find v3 attached. Please let me know if it fixes the test issue. Best regards, Bob On Thu, Apr 16, 2026 at 12:31=E2=80=AFPM Tatsuo Ishii wrote: > Hi Bob, > > Thank you for the patch! > > Unfortunately after applying the patch, the test failed. From > src/test/regression/log/042.ssl_reload: > > =3D=3D=3D=3D=3D ssl_ca_cert swap (client cert auth reload) =3D=3D=3D=3D= =3D > waiting for server to start....1462289 2026-04-16 19:25:49.490 JST LOG: > redirecting log output to logging collector process > 1462289 2026-04-16 19:25:49.490 JST HINT: Future log output will appear > in directory "log". > done > server started > CA cert swap: CA1-signed client cert rejected before reload =E2=80=93 une= xpected. > > From pgpool.log: > > 2026-04-16 19:26:10.150: child pid 1462331: DETAIL: Protocol Major: 1234 > Minor: 5679 database: user: > 2026-04-16 19:26:10.150: child pid 1462331: DEBUG: selecting backend > connection > 2026-04-16 19:26:10.150: child pid 1462331: DETAIL: SSLRequest from clie= nt > 2026-04-16 19:26:10.150: child pid 1462331: DEBUG: pool_write: to > frontend: kind:S po:0 > 2026-04-16 19:26:10.150: child pid 1462331: DEBUG: pool_flush_it: flush > size: 1 > 2026-04-16 19:26:10.167: child pid 1462331: LOG: pool_ssl: "SSL_accept": > "tlsv1 alert unknown ca" > 2026-04-16 19:26:10.167: child pid 1462331: DEBUG: unable to read data > from frontend > 2026-04-16 19:26:10.167: child pid 1462331: DETAIL: socket read failed > with error "Connection reset by peer" > > Please let me know if you need more info. > > Regards, > -- > Tatsuo Ishii > SRA OSS K.K. > English: http://www.sraoss.co.jp/index_en/ > Japanese:http://www.sraoss.co.jp > > > Hi Tatsuo, > > > > Please see attached v2. It adds regression coverage for SSL cert reload > > with client certificate authentication; there are no functional code > > changes. > > > > Best regards, > > Bob > > > > > > On Tue, Apr 14, 2026 at 10:02=E2=80=AFAM Tatsuo Ishii > wrote: > > > >> Hi Bob, > >> > >> > Hi Tatsuo, > >> > > >> > Please let me know if you need any assistance with updating your tes= t > >> > cases. I am be happy to help. > >> > > >> > Thanks, > >> > Bob > >> > >> Sorry for late. I was busy with personal affairs and some other > >> projects. > >> > >> > On Thu, Apr 2, 2026 at 9:57=E2=80=AFPM Bob Ross > >> wrote: > >> > > >> >> Hi Tatsuo, > >> >> > >> >> Thanks for putting together the regression tests. > >> >> > >> >> Thoughts on your questions: > >> >> - CA Certificates - Yes, adding a cert auth test is highly > recommended. > >> We > >> >> could test this by generating two different dummy CA certificates. > Start > >> >> pgpool trusting CA #1, swap the config to CA #2, reload and verify = if > >> >> client connection correctly gets rejected. > >> > >> If you could extend the test file I posted so that it performs a cert > >> auth test, that would be helpful. > >> > >> >> - DH parameters - perhaps we can test this by providing a > non-existent > >> >> file path and then use grep to check pgpool.log for specific warnin= g > >> >> message (per pool_ssl.c it=E2=80=99s =E2=80=9CDH: could not load DH= parameters=E2=80=9D) when > >> >> pgpool tries to load the file. > >> > >> I think it will not work. > >> > >> =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D > >> static bool > >> initialize_dh(SSL_CTX *context) > >> { > >> DH *dh =3D NULL; > >> > >> SSL_CTX_set_options(context, SSL_OP_SINGLE_DH_USE); > >> > >> if (pool_config->ssl_dh_params_file[0]) > >> dh =3D load_dh_file(pool_config->ssl_dh_params_file); > >> if (!dh) > >> dh =3D load_dh_buffer(FILE_DH2048, sizeof(FILE_DH2048)= ); > >> if (!dh) > >> { > >> ereport(WARNING, > >> (errmsg("DH: could not load DH > >> parameters"))); > >> return false; > >> } > >> : > >> : > >> =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D > >> > >> The ereport message is printed when the built-in DH parameter file is > >> broken. But as long as the source file is fine, it would never happen. > >> > >> Maybe we should fix the code above so that it emits ereport when it > >> fails to load the DH parameter file specified by ssl_dh_params_file? > >> > >> Regards, > >> -- > >> Tatsuo Ishii > >> SRA OSS K.K. > >> English: http://www.sraoss.co.jp/index_en/ > >> Japanese:http://www.sraoss.co.jp > >> > --000000000000a0a5ba064f92ed65 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Hi Tatsuo,

Thank you for the repor= t and the log, that was very helpful.

The bug was in the test, not i= n the core patch. Test 4 in 042.ssl_reload set PGSSLROOTCERT=3D"$CADIR= /ca1.crt" on both psql invocations. The intent was to use ca1.crt for = server-side client-certificate verification, but PGSSLROOTCERT actually con= trols client-side server certificate verification, and ca1.crt is a freshly= generated CA that never signed pgpool's server.crt. Because libpq upgr= ades sslmode=3Drequire to verify-ca behavior when a root CA file is provide= d, psql immediately sent unknown_ca back to pgpool and aborted the handshak= e before server-side client-cert verification ever ran.

Fix: both li= nes now use PGSSLROOTCERT=3D"etc/$SSL_CRT". Since server.crt is s= elf-signed it acts as its own root, so psql accepts pgpool's server cer= t, the handshake completes, and the test exercises what it was always meant= to test: whether pgpool enforces the new ssl_ca_cert after reload.

=
No changes to the core patch.

Please find v3 attached. Please l= et me know if it fixes the test issue.

Best regards,
Bob

On Thu, Apr 16, 2026 at 12:31=E2=80=AFPM Tatsuo I= shii <ishii@postgresql.org&g= t; wrote:
Hi Bob= ,

Thank you for the patch!

Unfortunately after applying the patch, the test failed. From
src/test/regression/log/042.ssl_reload:

=3D=3D=3D=3D=3D ssl_ca_cert swap (client cert auth reload) =3D=3D=3D=3D=3D<= br> waiting for server to start....1462289 2026-04-16 19:25:49.490 JST LOG:=C2= =A0 redirecting log output to logging collector process
1462289 2026-04-16 19:25:49.490 JST HINT:=C2=A0 Future log output will appe= ar in directory "log".
=C2=A0done
server started
CA cert swap: CA1-signed client cert rejected before reload =E2=80=93 unexp= ected.