Skip to content

Commit 2b0dbbd

Browse files
kovant8m
authored andcommitted
doc: clarify SSL_SESSION ownership in PSK use session callback
Document that when the psk_use_session callback is invoked multiple times and wishes to return the same SSL_SESSION pointer, it must call SSL_SESSION_up_ref() first since ownership is transferred on each call. This prevents use-after-free errors from incorrect callback implementations. Fixes #28267 Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> Reviewed-by: Neil Horman <nhorman@openssl.org> Reviewed-by: Eugene Syromiatnikov <esyr@openssl.org> Reviewed-by: Tomas Mraz <tomas@openssl.org> MergeDate: Fri Feb 13 14:36:50 2026 (Merged from #29771) (cherry picked from commit 6d646a9)
1 parent 9650d18 commit 2b0dbbd

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

doc/man3/SSL_CTX_set_psk_client_callback.pod

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,14 @@ be used as the basis for a PSK.
9393
Ownership of the SSL_SESSION object is passed to the OpenSSL library and so it
9494
should not be freed by the application.
9595

96+
Note that as described above, the callback may be called a second time during a
97+
handshake. Since ownership of the SSL_SESSION is transferred to OpenSSL on each
98+
call, if the callback wishes to return the same SSL_SESSION pointer on a
99+
subsequent invocation, it must first call L<SSL_SESSION_up_ref(3)> to increment
100+
the reference count. Failure to do so will result in a use-after-free error.
101+
Alternatively, the callback may return a different SSL_SESSION object on each
102+
call (e.g., by calling L<SSL_SESSION_dup(3)>).
103+
96104
It is also possible for the callback to succeed but not supply a PSK. In this
97105
case no PSK will be sent to the server but the handshake will continue. To do
98106
this the callback should return successfully and ensure that B<*sess> is

0 commit comments

Comments
 (0)