pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
pgsql: Fix handling of SCRAM-SHA-256's channel binding with RSA-PSS cer
6+ messages / 1 participants
[nested] [flat]

* pgsql: Fix handling of SCRAM-SHA-256's channel binding with RSA-PSS cer
@ 2023-02-15 01:14  Michael Paquier <michael@paquier.xyz>
  0 siblings, 0 replies; 6+ messages in thread

From: Michael Paquier @ 2023-02-15 01:14 UTC (permalink / raw)
  To: pgsql-committers@lists.postgresql.org

Fix handling of SCRAM-SHA-256's channel binding with RSA-PSS certificates

OpenSSL 1.1.1 and newer versions have added support for RSA-PSS
certificates, which requires the use of a specific routine in OpenSSL to
determine which hash function to use when compiling it when using
channel binding in SCRAM-SHA-256.  X509_get_signature_nid(), that is the
original routine the channel binding code has relied on, is not able to
determine which hash algorithm to use for such certificates.  However,
X509_get_signature_info(), new to OpenSSL 1.1.1, is able to do it.  This
commit switches the channel binding logic to rely on
X509_get_signature_info() over X509_get_signature_nid(), which would be
the choice when building with 1.1.1 or newer.

The error could have been triggered on the client or the server, hence
libpq and the backend need to have their related code paths patched.
Note that attempting to load an RSA-PSS certificate with OpenSSL 1.1.0
or older leads to a failure due to an unsupported algorithm.

The discovery of relying on X509_get_signature_info() comes from Jacob,
the tests have been written by Heikki (with few tweaks from me), while I
have bundled the whole together while adding the bits needed for MSVC
and meson.

This issue exists since channel binding exists, so backpatch all the way
down.  Some tests are added in 15~, triggered if compiling with OpenSSL
1.1.1 or newer, where the certificate and key files can easily be
generated for RSA-PSS.

Reported-by: Gunnar "Nick" Bluth
Author: Jacob Champion, Heikki Linnakangas
Discussion: https://postgr.es/m/17760-b6c61e752ec07060@postgresql.org
Backpatch-through: 11

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/9244c11afe23bce9358de3d36404151139e968d9

Modified Files
--------------
configure                                | 12 ++++++++++++
configure.ac                             |  2 ++
meson.build                              |  3 +++
src/backend/libpq/be-secure-openssl.c    |  9 +++++++--
src/include/libpq/libpq-be.h             |  2 +-
src/include/pg_config.h.in               |  3 +++
src/interfaces/libpq/fe-secure-openssl.c |  9 +++++++--
src/interfaces/libpq/libpq-int.h         |  2 +-
src/test/ssl/README                      |  1 +
src/test/ssl/conf/server-rsapss.config   | 14 ++++++++++++++
src/test/ssl/ssl/server-rsapss.crt       | 21 +++++++++++++++++++++
src/test/ssl/ssl/server-rsapss.key       | 28 ++++++++++++++++++++++++++++
src/test/ssl/sslfiles.mk                 | 26 ++++++++++++++++++++++----
src/test/ssl/t/002_scram.pl              | 17 +++++++++++++++++
src/tools/msvc/Solution.pm               | 10 +++++++++-
15 files changed, 148 insertions(+), 11 deletions(-)



^ permalink  raw  reply  [nested|flat] 6+ messages in thread

* pgsql: Fix handling of SCRAM-SHA-256's channel binding with RSA-PSS cer
@ 2023-02-15 01:14  Michael Paquier <michael@paquier.xyz>
  0 siblings, 0 replies; 6+ messages in thread

From: Michael Paquier @ 2023-02-15 01:14 UTC (permalink / raw)
  To: pgsql-committers@lists.postgresql.org

Fix handling of SCRAM-SHA-256's channel binding with RSA-PSS certificates

OpenSSL 1.1.1 and newer versions have added support for RSA-PSS
certificates, which requires the use of a specific routine in OpenSSL to
determine which hash function to use when compiling it when using
channel binding in SCRAM-SHA-256.  X509_get_signature_nid(), that is the
original routine the channel binding code has relied on, is not able to
determine which hash algorithm to use for such certificates.  However,
X509_get_signature_info(), new to OpenSSL 1.1.1, is able to do it.  This
commit switches the channel binding logic to rely on
X509_get_signature_info() over X509_get_signature_nid(), which would be
the choice when building with 1.1.1 or newer.

The error could have been triggered on the client or the server, hence
libpq and the backend need to have their related code paths patched.
Note that attempting to load an RSA-PSS certificate with OpenSSL 1.1.0
or older leads to a failure due to an unsupported algorithm.

The discovery of relying on X509_get_signature_info() comes from Jacob,
the tests have been written by Heikki (with few tweaks from me), while I
have bundled the whole together while adding the bits needed for MSVC
and meson.

This issue exists since channel binding exists, so backpatch all the way
down.  Some tests are added in 15~, triggered if compiling with OpenSSL
1.1.1 or newer, where the certificate and key files can easily be
generated for RSA-PSS.

Reported-by: Gunnar "Nick" Bluth
Author: Jacob Champion, Heikki Linnakangas
Discussion: https://postgr.es/m/17760-b6c61e752ec07060@postgresql.org
Backpatch-through: 11

Branch
------
REL_15_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/5fd61055eacf3d0c45be20b90402a87c9848db43

Modified Files
--------------
configure                                | 12 ++++++++++++
configure.ac                             |  2 ++
src/backend/libpq/be-secure-openssl.c    |  9 +++++++--
src/include/libpq/libpq-be.h             |  2 +-
src/include/pg_config.h.in               |  3 +++
src/interfaces/libpq/fe-secure-openssl.c |  9 +++++++--
src/interfaces/libpq/libpq-int.h         |  2 +-
src/test/ssl/README                      |  1 +
src/test/ssl/conf/server-rsapss.config   | 14 ++++++++++++++
src/test/ssl/ssl/server-rsapss.crt       | 21 +++++++++++++++++++++
src/test/ssl/ssl/server-rsapss.key       | 28 ++++++++++++++++++++++++++++
src/test/ssl/sslfiles.mk                 | 26 ++++++++++++++++++++++----
src/test/ssl/t/002_scram.pl              | 17 +++++++++++++++++
src/tools/msvc/Solution.pm               | 10 +++++++++-
14 files changed, 145 insertions(+), 11 deletions(-)



^ permalink  raw  reply  [nested|flat] 6+ messages in thread

* pgsql: Fix handling of SCRAM-SHA-256's channel binding with RSA-PSS cer
@ 2023-02-15 01:14  Michael Paquier <michael@paquier.xyz>
  0 siblings, 0 replies; 6+ messages in thread

From: Michael Paquier @ 2023-02-15 01:14 UTC (permalink / raw)
  To: pgsql-committers@lists.postgresql.org

Fix handling of SCRAM-SHA-256's channel binding with RSA-PSS certificates

OpenSSL 1.1.1 and newer versions have added support for RSA-PSS
certificates, which requires the use of a specific routine in OpenSSL to
determine which hash function to use when compiling it when using
channel binding in SCRAM-SHA-256.  X509_get_signature_nid(), that is the
original routine the channel binding code has relied on, is not able to
determine which hash algorithm to use for such certificates.  However,
X509_get_signature_info(), new to OpenSSL 1.1.1, is able to do it.  This
commit switches the channel binding logic to rely on
X509_get_signature_info() over X509_get_signature_nid(), which would be
the choice when building with 1.1.1 or newer.

The error could have been triggered on the client or the server, hence
libpq and the backend need to have their related code paths patched.
Note that attempting to load an RSA-PSS certificate with OpenSSL 1.1.0
or older leads to a failure due to an unsupported algorithm.

The discovery of relying on X509_get_signature_info() comes from Jacob,
the tests have been written by Heikki (with few tweaks from me), while I
have bundled the whole together while adding the bits needed for MSVC
and meson.

This issue exists since channel binding exists, so backpatch all the way
down.  Some tests are added in 15~, triggered if compiling with OpenSSL
1.1.1 or newer, where the certificate and key files can easily be
generated for RSA-PSS.

Reported-by: Gunnar "Nick" Bluth
Author: Jacob Champion, Heikki Linnakangas
Discussion: https://postgr.es/m/17760-b6c61e752ec07060@postgresql.org
Backpatch-through: 11

Branch
------
REL_14_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/864f80feadea85fae70abe3fa9d89408b93547d2

Modified Files
--------------
configure                                | 12 ++++++++++++
configure.ac                             |  2 ++
src/backend/libpq/be-secure-openssl.c    |  9 +++++++--
src/include/libpq/libpq-be.h             |  2 +-
src/include/pg_config.h.in               |  3 +++
src/interfaces/libpq/fe-secure-openssl.c |  9 +++++++--
src/interfaces/libpq/libpq-int.h         |  2 +-
src/tools/msvc/Solution.pm               | 10 +++++++++-
8 files changed, 42 insertions(+), 7 deletions(-)



^ permalink  raw  reply  [nested|flat] 6+ messages in thread

* pgsql: Fix handling of SCRAM-SHA-256's channel binding with RSA-PSS cer
@ 2023-02-15 01:14  Michael Paquier <michael@paquier.xyz>
  0 siblings, 0 replies; 6+ messages in thread

From: Michael Paquier @ 2023-02-15 01:14 UTC (permalink / raw)
  To: pgsql-committers@lists.postgresql.org

Fix handling of SCRAM-SHA-256's channel binding with RSA-PSS certificates

OpenSSL 1.1.1 and newer versions have added support for RSA-PSS
certificates, which requires the use of a specific routine in OpenSSL to
determine which hash function to use when compiling it when using
channel binding in SCRAM-SHA-256.  X509_get_signature_nid(), that is the
original routine the channel binding code has relied on, is not able to
determine which hash algorithm to use for such certificates.  However,
X509_get_signature_info(), new to OpenSSL 1.1.1, is able to do it.  This
commit switches the channel binding logic to rely on
X509_get_signature_info() over X509_get_signature_nid(), which would be
the choice when building with 1.1.1 or newer.

The error could have been triggered on the client or the server, hence
libpq and the backend need to have their related code paths patched.
Note that attempting to load an RSA-PSS certificate with OpenSSL 1.1.0
or older leads to a failure due to an unsupported algorithm.

The discovery of relying on X509_get_signature_info() comes from Jacob,
the tests have been written by Heikki (with few tweaks from me), while I
have bundled the whole together while adding the bits needed for MSVC
and meson.

This issue exists since channel binding exists, so backpatch all the way
down.  Some tests are added in 15~, triggered if compiling with OpenSSL
1.1.1 or newer, where the certificate and key files can easily be
generated for RSA-PSS.

Reported-by: Gunnar "Nick" Bluth
Author: Jacob Champion, Heikki Linnakangas
Discussion: https://postgr.es/m/17760-b6c61e752ec07060@postgresql.org
Backpatch-through: 11

Branch
------
REL_13_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/2eb8e54cc373e4e4f9ecf7360563912f9c40ad76

Modified Files
--------------
configure                                | 12 ++++++++++++
configure.in                             |  2 ++
src/backend/libpq/be-secure-openssl.c    |  9 +++++++--
src/include/libpq/libpq-be.h             |  2 +-
src/include/pg_config.h.in               |  3 +++
src/interfaces/libpq/fe-secure-openssl.c |  9 +++++++--
src/interfaces/libpq/libpq-int.h         |  2 +-
src/tools/msvc/Solution.pm               | 10 +++++++++-
8 files changed, 42 insertions(+), 7 deletions(-)



^ permalink  raw  reply  [nested|flat] 6+ messages in thread

* pgsql: Fix handling of SCRAM-SHA-256's channel binding with RSA-PSS cer
@ 2023-02-15 01:14  Michael Paquier <michael@paquier.xyz>
  0 siblings, 0 replies; 6+ messages in thread

From: Michael Paquier @ 2023-02-15 01:14 UTC (permalink / raw)
  To: pgsql-committers@lists.postgresql.org

Fix handling of SCRAM-SHA-256's channel binding with RSA-PSS certificates

OpenSSL 1.1.1 and newer versions have added support for RSA-PSS
certificates, which requires the use of a specific routine in OpenSSL to
determine which hash function to use when compiling it when using
channel binding in SCRAM-SHA-256.  X509_get_signature_nid(), that is the
original routine the channel binding code has relied on, is not able to
determine which hash algorithm to use for such certificates.  However,
X509_get_signature_info(), new to OpenSSL 1.1.1, is able to do it.  This
commit switches the channel binding logic to rely on
X509_get_signature_info() over X509_get_signature_nid(), which would be
the choice when building with 1.1.1 or newer.

The error could have been triggered on the client or the server, hence
libpq and the backend need to have their related code paths patched.
Note that attempting to load an RSA-PSS certificate with OpenSSL 1.1.0
or older leads to a failure due to an unsupported algorithm.

The discovery of relying on X509_get_signature_info() comes from Jacob,
the tests have been written by Heikki (with few tweaks from me), while I
have bundled the whole together while adding the bits needed for MSVC
and meson.

This issue exists since channel binding exists, so backpatch all the way
down.  Some tests are added in 15~, triggered if compiling with OpenSSL
1.1.1 or newer, where the certificate and key files can easily be
generated for RSA-PSS.

Reported-by: Gunnar "Nick" Bluth
Author: Jacob Champion, Heikki Linnakangas
Discussion: https://postgr.es/m/17760-b6c61e752ec07060@postgresql.org
Backpatch-through: 11

Branch
------
REL_12_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/a40e7b75e689c3f7f9c9c77106a1ff59fa61d938

Modified Files
--------------
configure                                | 12 ++++++++++++
configure.in                             |  2 ++
src/backend/libpq/be-secure-openssl.c    |  9 +++++++--
src/include/libpq/libpq-be.h             |  2 +-
src/include/pg_config.h.in               |  3 +++
src/interfaces/libpq/fe-secure-openssl.c |  9 +++++++--
src/interfaces/libpq/libpq-int.h         |  2 +-
src/tools/msvc/Solution.pm               |  9 ++++++++-
8 files changed, 41 insertions(+), 7 deletions(-)



^ permalink  raw  reply  [nested|flat] 6+ messages in thread

* pgsql: Fix handling of SCRAM-SHA-256's channel binding with RSA-PSS cer
@ 2023-02-15 01:14  Michael Paquier <michael@paquier.xyz>
  0 siblings, 0 replies; 6+ messages in thread

From: Michael Paquier @ 2023-02-15 01:14 UTC (permalink / raw)
  To: pgsql-committers@lists.postgresql.org

Fix handling of SCRAM-SHA-256's channel binding with RSA-PSS certificates

OpenSSL 1.1.1 and newer versions have added support for RSA-PSS
certificates, which requires the use of a specific routine in OpenSSL to
determine which hash function to use when compiling it when using
channel binding in SCRAM-SHA-256.  X509_get_signature_nid(), that is the
original routine the channel binding code has relied on, is not able to
determine which hash algorithm to use for such certificates.  However,
X509_get_signature_info(), new to OpenSSL 1.1.1, is able to do it.  This
commit switches the channel binding logic to rely on
X509_get_signature_info() over X509_get_signature_nid(), which would be
the choice when building with 1.1.1 or newer.

The error could have been triggered on the client or the server, hence
libpq and the backend need to have their related code paths patched.
Note that attempting to load an RSA-PSS certificate with OpenSSL 1.1.0
or older leads to a failure due to an unsupported algorithm.

The discovery of relying on X509_get_signature_info() comes from Jacob,
the tests have been written by Heikki (with few tweaks from me), while I
have bundled the whole together while adding the bits needed for MSVC
and meson.

This issue exists since channel binding exists, so backpatch all the way
down.  Some tests are added in 15~, triggered if compiling with OpenSSL
1.1.1 or newer, where the certificate and key files can easily be
generated for RSA-PSS.

Reported-by: Gunnar "Nick" Bluth
Author: Jacob Champion, Heikki Linnakangas
Discussion: https://postgr.es/m/17760-b6c61e752ec07060@postgresql.org
Backpatch-through: 11

Branch
------
REL_11_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/88d606f7cc68aa753868ca92b0e065d77c5915d2

Modified Files
--------------
configure                                | 12 ++++++++++++
configure.in                             |  2 ++
src/backend/libpq/be-secure-openssl.c    |  9 +++++++--
src/include/libpq/libpq-be.h             |  2 +-
src/include/pg_config.h.in               |  3 +++
src/interfaces/libpq/fe-secure-openssl.c |  9 +++++++--
src/interfaces/libpq/libpq-int.h         |  2 +-
src/tools/msvc/Solution.pm               |  9 ++++++++-
8 files changed, 41 insertions(+), 7 deletions(-)



^ permalink  raw  reply  [nested|flat] 6+ messages in thread


end of thread, other threads:[~2023-02-15 01:14 UTC | newest]

Thread overview: 6+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2023-02-15 01:14 pgsql: Fix handling of SCRAM-SHA-256's channel binding with RSA-PSS cer Michael Paquier <michael@paquier.xyz>
2023-02-15 01:14 pgsql: Fix handling of SCRAM-SHA-256's channel binding with RSA-PSS cer Michael Paquier <michael@paquier.xyz>
2023-02-15 01:14 pgsql: Fix handling of SCRAM-SHA-256's channel binding with RSA-PSS cer Michael Paquier <michael@paquier.xyz>
2023-02-15 01:14 pgsql: Fix handling of SCRAM-SHA-256's channel binding with RSA-PSS cer Michael Paquier <michael@paquier.xyz>
2023-02-15 01:14 pgsql: Fix handling of SCRAM-SHA-256's channel binding with RSA-PSS cer Michael Paquier <michael@paquier.xyz>
2023-02-15 01:14 pgsql: Fix handling of SCRAM-SHA-256's channel binding with RSA-PSS cer Michael Paquier <michael@paquier.xyz>

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox