Skip to content

Commit 1f476bc

Browse files
Disable all TLS session tickets
OpenSSL supports two types of session tickets for TLSv1.3, stateless and stateful. The option we've used only turns off stateless tickets leaving stateful tickets active. Use the new API introduced in 1.1.1 to disable all types of tickets. Backpatch to all supported versions. Reviewed-by: Heikki Linnakangas <hlinnaka@iki.fi> Reported-by: Andres Freund <andres@anarazel.de> Discussion: https://postgr.es/m/20240617173803.6alnafnxpiqvlh3g@awork3.anarazel.de Backpatch-through: v12
1 parent c0ba7d6 commit 1f476bc

File tree

4 files changed

+22
-6
lines changed

4 files changed

+22
-6
lines changed

configure

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12740,12 +12740,13 @@ fi
1274012740
done
1274112741

1274212742
# Function introduced in OpenSSL 1.1.1.
12743-
for ac_func in X509_get_signature_info
12743+
for ac_func in X509_get_signature_info SSL_CTX_set_num_tickets
1274412744
do :
12745-
ac_fn_c_check_func "$LINENO" "X509_get_signature_info" "ac_cv_func_X509_get_signature_info"
12746-
if test "x$ac_cv_func_X509_get_signature_info" = xyes; then :
12745+
as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh`
12746+
ac_fn_c_check_func "$LINENO" "$ac_func" "$as_ac_var"
12747+
if eval test \"x\$"$as_ac_var"\" = x"yes"; then :
1274712748
cat >>confdefs.h <<_ACEOF
12748-
#define HAVE_X509_GET_SIGNATURE_INFO 1
12749+
#define `$as_echo "HAVE_$ac_func" | $as_tr_cpp` 1
1274912750
_ACEOF
1275012751

1275112752
fi

configure.in

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1281,7 +1281,7 @@ if test "$with_openssl" = yes ; then
12811281
# function was removed.
12821282
AC_CHECK_FUNCS([CRYPTO_lock])
12831283
# Function introduced in OpenSSL 1.1.1.
1284-
AC_CHECK_FUNCS([X509_get_signature_info])
1284+
AC_CHECK_FUNCS([X509_get_signature_info SSL_CTX_set_num_tickets])
12851285
fi
12861286

12871287
if test "$with_pam" = yes ; then

src/backend/libpq/be-secure-openssl.c

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -242,8 +242,20 @@ be_tls_init(bool isServerStart)
242242
}
243243
}
244244

245-
/* disallow SSL session tickets */
245+
/*
246+
* Disallow SSL session tickets. OpenSSL use both stateful and stateless
247+
* tickets for TLSv1.3, and stateless ticket for TLSv1.2. SSL_OP_NO_TICKET
248+
* is available since 0.9.8f but only turns off stateless tickets. In
249+
* order to turn off stateful tickets we need SSL_CTX_set_num_tickets,
250+
* which is available since OpenSSL 1.1.1. LibreSSL 3.5.4 (from OpenBSD
251+
* 7.1) introduced this API for compatibility, but doesn't support session
252+
* tickets at all so it's a no-op there.
253+
*/
254+
#ifdef HAVE_SSL_CTX_SET_NUM_TICKETS
255+
SSL_CTX_set_num_tickets(context, 0);
256+
#else
246257
SSL_CTX_set_options(context, SSL_OP_NO_TICKET);
258+
#endif
247259

248260
/* disallow SSL session caching, too */
249261
SSL_CTX_set_session_cache_mode(context, SSL_SESS_CACHE_OFF);

src/include/pg_config.h.in

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -686,6 +686,9 @@
686686
/* Define to 1 if you have the `X509_get_signature_nid' function. */
687687
#undef HAVE_X509_GET_SIGNATURE_NID
688688

689+
/* Define to 1 if you have the `SSL_CTX_set_num_tickets' function. */
690+
#undef HAVE_SSL_CTX_SET_NUM_TICKETS
691+
689692
/* Define to 1 if the assembler supports X86_64's POPCNTQ instruction. */
690693
#undef HAVE_X86_64_POPCNTQ
691694

0 commit comments

Comments
 (0)