pg.ddx.io pgsql-committers@postgresql.org mailing list archivehelp / color / mirror / Atom feed
pgsql: Don't share SSL_CTX between libpq connections. 7+ messages / 1 participants [nested] [flat]
* pgsql: Don't share SSL_CTX between libpq connections. @ 2016-10-07 09:25 Heikki Linnakangas <heikki.linnakangas@iki.fi> 0 siblings, 0 replies; 7+ messages in thread From: Heikki Linnakangas @ 2016-10-07 09:25 UTC (permalink / raw) To: pgsql-committers Don't share SSL_CTX between libpq connections. There were several issues with the old coding: 1. There was a race condition, if two threads opened a connection at the same time. We used a mutex around SSL_CTX_* calls, but that was not enough, e.g. if one thread SSL_CTX_load_verify_locations() with one path, and another thread set it with a different path, before the first thread got to establish the connection. 2. Opening two different connections, with different sslrootcert settings, seemed to fail outright with "SSL error: block type is not 01". Not sure why. 3. We created the SSL object, before calling SSL_CTX_load_verify_locations and SSL_CTX_use_certificate_chain_file on the SSL context. That was wrong, because the options set on the SSL context are propagated to the SSL object, when the SSL object is created. If they are set after the SSL object has already been created, they won't take effect until the next connection. (This is bug #14329) At least some of these could've been fixed while still using a shared context, but it would've been more complicated and error-prone. To keep things simple, let's just use a separate SSL context for each connection, and accept the overhead. Backpatch to all supported versions. Report, analysis and test case by Kacper Zuk. Discussion: <20160920101051.1355.79453@wrigleys.postgresql.org> Branch ------ master Details ------- http://git.postgresql.org/pg/commitdiff/8bb14cdd33deecc6977cf5638f73e80f76ab658b Modified Files -------------- src/interfaces/libpq/fe-secure-openssl.c | 397 +++++++++++++------------------ src/test/ssl/Makefile | 6 +- src/test/ssl/README | 4 + src/test/ssl/ServerSetup.pm | 6 +- src/test/ssl/ssl/client+client_ca.crt | 25 ++ src/test/ssl/t/001_ssltests.pl | 10 +- 6 files changed, 211 insertions(+), 237 deletions(-) -- Sent via pgsql-committers mailing list (pgsql-committers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-committers ^ permalink raw reply [nested|flat] 7+ messages in thread
* pgsql: Don't share SSL_CTX between libpq connections. @ 2016-10-07 09:25 Heikki Linnakangas <heikki.linnakangas@iki.fi> 0 siblings, 0 replies; 7+ messages in thread From: Heikki Linnakangas @ 2016-10-07 09:25 UTC (permalink / raw) To: pgsql-committers Don't share SSL_CTX between libpq connections. There were several issues with the old coding: 1. There was a race condition, if two threads opened a connection at the same time. We used a mutex around SSL_CTX_* calls, but that was not enough, e.g. if one thread SSL_CTX_load_verify_locations() with one path, and another thread set it with a different path, before the first thread got to establish the connection. 2. Opening two different connections, with different sslrootcert settings, seemed to fail outright with "SSL error: block type is not 01". Not sure why. 3. We created the SSL object, before calling SSL_CTX_load_verify_locations and SSL_CTX_use_certificate_chain_file on the SSL context. That was wrong, because the options set on the SSL context are propagated to the SSL object, when the SSL object is created. If they are set after the SSL object has already been created, they won't take effect until the next connection. (This is bug #14329) At least some of these could've been fixed while still using a shared context, but it would've been more complicated and error-prone. To keep things simple, let's just use a separate SSL context for each connection, and accept the overhead. Backpatch to all supported versions. Report, analysis and test case by Kacper Zuk. Discussion: <20160920101051.1355.79453@wrigleys.postgresql.org> Branch ------ REL9_6_STABLE Details ------- http://git.postgresql.org/pg/commitdiff/341acf235943c15aa56103ef7b66ecec625b4af0 Modified Files -------------- src/interfaces/libpq/fe-secure-openssl.c | 397 +++++++++++++------------------ src/test/ssl/Makefile | 6 +- src/test/ssl/README | 4 + src/test/ssl/ServerSetup.pm | 6 +- src/test/ssl/ssl/client+client_ca.crt | 25 ++ src/test/ssl/t/001_ssltests.pl | 10 +- 6 files changed, 211 insertions(+), 237 deletions(-) -- Sent via pgsql-committers mailing list (pgsql-committers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-committers ^ permalink raw reply [nested|flat] 7+ messages in thread
* pgsql: Don't share SSL_CTX between libpq connections. @ 2016-10-07 09:25 Heikki Linnakangas <heikki.linnakangas@iki.fi> 0 siblings, 0 replies; 7+ messages in thread From: Heikki Linnakangas @ 2016-10-07 09:25 UTC (permalink / raw) To: pgsql-committers Don't share SSL_CTX between libpq connections. There were several issues with the old coding: 1. There was a race condition, if two threads opened a connection at the same time. We used a mutex around SSL_CTX_* calls, but that was not enough, e.g. if one thread SSL_CTX_load_verify_locations() with one path, and another thread set it with a different path, before the first thread got to establish the connection. 2. Opening two different connections, with different sslrootcert settings, seemed to fail outright with "SSL error: block type is not 01". Not sure why. 3. We created the SSL object, before calling SSL_CTX_load_verify_locations and SSL_CTX_use_certificate_chain_file on the SSL context. That was wrong, because the options set on the SSL context are propagated to the SSL object, when the SSL object is created. If they are set after the SSL object has already been created, they won't take effect until the next connection. (This is bug #14329) At least some of these could've been fixed while still using a shared context, but it would've been more complicated and error-prone. To keep things simple, let's just use a separate SSL context for each connection, and accept the overhead. Backpatch to all supported versions. Report, analysis and test case by Kacper Zuk. Discussion: <20160920101051.1355.79453@wrigleys.postgresql.org> Branch ------ REL9_5_STABLE Details ------- http://git.postgresql.org/pg/commitdiff/cb38c056fda53234dcc7f7d10bd08dd5a277c92e Modified Files -------------- src/interfaces/libpq/fe-secure-openssl.c | 397 +++++++++++++------------------ src/test/ssl/Makefile | 6 +- src/test/ssl/README | 4 + src/test/ssl/ServerSetup.pm | 6 +- src/test/ssl/ssl/client+client_ca.crt | 25 ++ src/test/ssl/t/001_ssltests.pl | 9 +- 6 files changed, 210 insertions(+), 237 deletions(-) -- Sent via pgsql-committers mailing list (pgsql-committers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-committers ^ permalink raw reply [nested|flat] 7+ messages in thread
* pgsql: Don't share SSL_CTX between libpq connections. @ 2016-10-07 09:25 Heikki Linnakangas <heikki.linnakangas@iki.fi> 0 siblings, 0 replies; 7+ messages in thread From: Heikki Linnakangas @ 2016-10-07 09:25 UTC (permalink / raw) To: pgsql-committers Don't share SSL_CTX between libpq connections. There were several issues with the old coding: 1. There was a race condition, if two threads opened a connection at the same time. We used a mutex around SSL_CTX_* calls, but that was not enough, e.g. if one thread SSL_CTX_load_verify_locations() with one path, and another thread set it with a different path, before the first thread got to establish the connection. 2. Opening two different connections, with different sslrootcert settings, seemed to fail outright with "SSL error: block type is not 01". Not sure why. 3. We created the SSL object, before calling SSL_CTX_load_verify_locations and SSL_CTX_use_certificate_chain_file on the SSL context. That was wrong, because the options set on the SSL context are propagated to the SSL object, when the SSL object is created. If they are set after the SSL object has already been created, they won't take effect until the next connection. (This is bug #14329) At least some of these could've been fixed while still using a shared context, but it would've been more complicated and error-prone. To keep things simple, let's just use a separate SSL context for each connection, and accept the overhead. Backpatch to all supported versions. Report, analysis and test case by Kacper Zuk. Discussion: <20160920101051.1355.79453@wrigleys.postgresql.org> Branch ------ REL9_4_STABLE Details ------- http://git.postgresql.org/pg/commitdiff/31895abd8bf1bf1841b47116874bcb447b9d33b0 Modified Files -------------- src/interfaces/libpq/fe-secure.c | 394 ++++++++++++++++----------------------- 1 file changed, 163 insertions(+), 231 deletions(-) -- Sent via pgsql-committers mailing list (pgsql-committers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-committers ^ permalink raw reply [nested|flat] 7+ messages in thread
* pgsql: Don't share SSL_CTX between libpq connections. @ 2016-10-07 09:25 Heikki Linnakangas <heikki.linnakangas@iki.fi> 0 siblings, 0 replies; 7+ messages in thread From: Heikki Linnakangas @ 2016-10-07 09:25 UTC (permalink / raw) To: pgsql-committers Don't share SSL_CTX between libpq connections. There were several issues with the old coding: 1. There was a race condition, if two threads opened a connection at the same time. We used a mutex around SSL_CTX_* calls, but that was not enough, e.g. if one thread SSL_CTX_load_verify_locations() with one path, and another thread set it with a different path, before the first thread got to establish the connection. 2. Opening two different connections, with different sslrootcert settings, seemed to fail outright with "SSL error: block type is not 01". Not sure why. 3. We created the SSL object, before calling SSL_CTX_load_verify_locations and SSL_CTX_use_certificate_chain_file on the SSL context. That was wrong, because the options set on the SSL context are propagated to the SSL object, when the SSL object is created. If they are set after the SSL object has already been created, they won't take effect until the next connection. (This is bug #14329) At least some of these could've been fixed while still using a shared context, but it would've been more complicated and error-prone. To keep things simple, let's just use a separate SSL context for each connection, and accept the overhead. Backpatch to all supported versions. Report, analysis and test case by Kacper Zuk. Discussion: <20160920101051.1355.79453@wrigleys.postgresql.org> Branch ------ REL9_3_STABLE Details ------- http://git.postgresql.org/pg/commitdiff/fde92dc226ebc355cd93ef443d116fc168b06968 Modified Files -------------- src/interfaces/libpq/fe-secure.c | 393 ++++++++++++++++----------------------- 1 file changed, 163 insertions(+), 230 deletions(-) -- Sent via pgsql-committers mailing list (pgsql-committers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-committers ^ permalink raw reply [nested|flat] 7+ messages in thread
* pgsql: Don't share SSL_CTX between libpq connections. @ 2016-10-07 09:25 Heikki Linnakangas <heikki.linnakangas@iki.fi> 0 siblings, 0 replies; 7+ messages in thread From: Heikki Linnakangas @ 2016-10-07 09:25 UTC (permalink / raw) To: pgsql-committers Don't share SSL_CTX between libpq connections. There were several issues with the old coding: 1. There was a race condition, if two threads opened a connection at the same time. We used a mutex around SSL_CTX_* calls, but that was not enough, e.g. if one thread SSL_CTX_load_verify_locations() with one path, and another thread set it with a different path, before the first thread got to establish the connection. 2. Opening two different connections, with different sslrootcert settings, seemed to fail outright with "SSL error: block type is not 01". Not sure why. 3. We created the SSL object, before calling SSL_CTX_load_verify_locations and SSL_CTX_use_certificate_chain_file on the SSL context. That was wrong, because the options set on the SSL context are propagated to the SSL object, when the SSL object is created. If they are set after the SSL object has already been created, they won't take effect until the next connection. (This is bug #14329) At least some of these could've been fixed while still using a shared context, but it would've been more complicated and error-prone. To keep things simple, let's just use a separate SSL context for each connection, and accept the overhead. Backpatch to all supported versions. Report, analysis and test case by Kacper Zuk. Discussion: <20160920101051.1355.79453@wrigleys.postgresql.org> Branch ------ REL9_2_STABLE Details ------- http://git.postgresql.org/pg/commitdiff/e7bb327e347212172b7db16af6721c39090aa5c5 Modified Files -------------- src/interfaces/libpq/fe-secure.c | 393 ++++++++++++++++----------------------- 1 file changed, 163 insertions(+), 230 deletions(-) -- Sent via pgsql-committers mailing list (pgsql-committers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-committers ^ permalink raw reply [nested|flat] 7+ messages in thread
* pgsql: Don't share SSL_CTX between libpq connections. @ 2016-10-07 09:25 Heikki Linnakangas <heikki.linnakangas@iki.fi> 0 siblings, 0 replies; 7+ messages in thread From: Heikki Linnakangas @ 2016-10-07 09:25 UTC (permalink / raw) To: pgsql-committers Don't share SSL_CTX between libpq connections. There were several issues with the old coding: 1. There was a race condition, if two threads opened a connection at the same time. We used a mutex around SSL_CTX_* calls, but that was not enough, e.g. if one thread SSL_CTX_load_verify_locations() with one path, and another thread set it with a different path, before the first thread got to establish the connection. 2. Opening two different connections, with different sslrootcert settings, seemed to fail outright with "SSL error: block type is not 01". Not sure why. 3. We created the SSL object, before calling SSL_CTX_load_verify_locations and SSL_CTX_use_certificate_chain_file on the SSL context. That was wrong, because the options set on the SSL context are propagated to the SSL object, when the SSL object is created. If they are set after the SSL object has already been created, they won't take effect until the next connection. (This is bug #14329) At least some of these could've been fixed while still using a shared context, but it would've been more complicated and error-prone. To keep things simple, let's just use a separate SSL context for each connection, and accept the overhead. Backpatch to all supported versions. Report, analysis and test case by Kacper Zuk. Discussion: <20160920101051.1355.79453@wrigleys.postgresql.org> Branch ------ REL9_1_STABLE Details ------- http://git.postgresql.org/pg/commitdiff/e76d06d7f29522285c34324078469e90e51af772 Modified Files -------------- src/interfaces/libpq/fe-secure.c | 393 ++++++++++++++++----------------------- 1 file changed, 163 insertions(+), 230 deletions(-) -- Sent via pgsql-committers mailing list (pgsql-committers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-committers ^ permalink raw reply [nested|flat] 7+ messages in thread
end of thread, other threads:[~2016-10-07 09:25 UTC | newest] Thread overview: 7+ messages (download: mbox mbox.gz follow: Atom feed) -- links below jump to the message on this page -- 2016-10-07 09:25 pgsql: Don't share SSL_CTX between libpq connections. Heikki Linnakangas <heikki.linnakangas@iki.fi> 2016-10-07 09:25 pgsql: Don't share SSL_CTX between libpq connections. Heikki Linnakangas <heikki.linnakangas@iki.fi> 2016-10-07 09:25 pgsql: Don't share SSL_CTX between libpq connections. Heikki Linnakangas <heikki.linnakangas@iki.fi> 2016-10-07 09:25 pgsql: Don't share SSL_CTX between libpq connections. Heikki Linnakangas <heikki.linnakangas@iki.fi> 2016-10-07 09:25 pgsql: Don't share SSL_CTX between libpq connections. Heikki Linnakangas <heikki.linnakangas@iki.fi> 2016-10-07 09:25 pgsql: Don't share SSL_CTX between libpq connections. Heikki Linnakangas <heikki.linnakangas@iki.fi> 2016-10-07 09:25 pgsql: Don't share SSL_CTX between libpq connections. Heikki Linnakangas <heikki.linnakangas@iki.fi>
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